protected new PutRecordsResult InnerPutRecords(PutRecordsRequest putRecordsParam)
        {
            // Decorate PutRecordsRequest if needed
            putRecordsParam = DecorateRecords(putRecordsParam);

            ObsWebServiceRequest obsWebServiceRequest = new DISWebServiceRequest();

            OBS.Runtime.Internal.IRequest requestobs = new DISDefaultRequest(obsWebServiceRequest, Constants.SERVICENAME)
            {
                HttpMethod = HttpMethodName.POST.ToString()
            };

            string resourcePath = ResourcePathBuilder.Standard()
                                  .WithProjectId(_disConfig.GetProjectId())
                                  .WithResource(new RecordResource(null))
                                  .Build();

            requestobs.ResourcePath = resourcePath;

            if (_disConfig.GetBodySerializeType().ToLower().Equals(BodySerializeType.Protobuf.ToString().ToLower()))
            {
                requestobs.Headers.Add("Content-Type", "application/x-protobuf; charset=utf-8");
                requestobs.Headers.Add("accept", "*/*");
                HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequest protoRequest = ProtobufUtils.ToProtobufPutRecordsRequest(putRecordsParam);
                HuaweiCloud.DIS.Api.Protobuf.PutRecordsResult  protoResult  = Request <HuaweiCloud.DIS.Api.Protobuf.PutRecordsResult>(protoRequest.ToByteArray(), requestobs, InterfaceType.DISInterfacePutRecords);
                PutRecordsResult result = ProtobufUtils.ToPutRecordsResult(protoResult);
                return(result);
            }
            else
            {
                var results = Request <PutRecordsResult>(putRecordsParam, requestobs);
                return(results);
            }
        }
 /// <summary>
 /// 流式数据上传
 /// </summary>
 /// <param name="putRecordsParam"></param>
 /// <returns></returns>
 public new PutRecordsResult PutRecords(PutRecordsRequest putRecordsParam)
 {
     return(InnerPutRecordsSupportingCache(putRecordsParam, new PutRecordMethod(this.InnerPutRecords)));
 }
Exemplo n.º 3
0
        /// <summary>
        /// 将标准请求类型的对象转换为protobuf的请求参数类型
        /// </summary>
        /// <param name="putRecordsParam"></param>
        /// <returns></returns>
        public static HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequest ToProtobufPutRecordsRequest(PutRecordsRequest putRecordsParam)
        {
            HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequest protobufRequest = new HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequest();
            protobufRequest.StreamName = putRecordsParam.StreamName;

            List <HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntry> protobufRecordsList = new List <HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntry>();

            foreach (PutRecordsRequestEntry putRecordsRequestEntry in putRecordsParam.Records)
            {
                HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntry protobufReqEntry = new HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntry();

                if (putRecordsRequestEntry.Data != null)
                {
                    protobufReqEntry.Data = ByteString.CopyFrom(putRecordsRequestEntry.Data.ToArray());
                }
                if (putRecordsRequestEntry.PartitionKey != null)
                {
                    protobufReqEntry.PartitionKey = putRecordsRequestEntry.PartitionKey;
                }
                if (putRecordsRequestEntry.ExplicitHashKey != null)
                {
                    protobufReqEntry.ExplicitHashKey = putRecordsRequestEntry.ExplicitHashKey;
                }
                if (putRecordsRequestEntry.PartitionId != null)
                {
                    protobufReqEntry.PartitionId = putRecordsRequestEntry.PartitionId;
                }


                PutRecordsRequestEntryExtendedInfo putRecordsRequestEntryExtendedInfo = putRecordsRequestEntry.ExtenedInfo;
                if (putRecordsRequestEntryExtendedInfo != null)
                {
                    HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntryExtendedInfo ProtobufExtendedInfo = new HuaweiCloud.DIS.Api.Protobuf.PutRecordsRequestEntryExtendedInfo();

                    if (putRecordsRequestEntryExtendedInfo.DeliverDataId != null)
                    {
                        ProtobufExtendedInfo.DeliverDataId = putRecordsRequestEntryExtendedInfo.DeliverDataId;
                    }

                    if (putRecordsRequestEntryExtendedInfo.FileName != null)
                    {
                        ProtobufExtendedInfo.FileName = putRecordsRequestEntryExtendedInfo.FileName;
                    }

                    ProtobufExtendedInfo.EndFlag = putRecordsRequestEntryExtendedInfo.EndFlag;

                    ProtobufExtendedInfo.SeqNum = putRecordsRequestEntryExtendedInfo.SequenceNumber;

                    protobufReqEntry.ExtendedInfo = ProtobufExtendedInfo;
                }

                protobufRecordsList.Add(protobufReqEntry);
            }

            protobufRequest.Records.Add(protobufRecordsList);
            return(protobufRequest);
        }