|
| 1 | +// using System.Collections.Concurrent; |
| 2 | +// using Microsoft.Extensions.Logging; |
| 3 | +// using Ydb.Topic; |
| 4 | + |
| 5 | +namespace Ydb.Sdk.Services.Topic; |
| 6 | + |
| 7 | +// using ProducerStream = Driver.BidirectionalStream< |
| 8 | +// StreamWriteMessage.Types.FromClient, |
| 9 | +// StreamWriteMessage.Types.FromServer |
| 10 | +// >; |
| 11 | + |
| 12 | +internal class Producer<TValue> : IProducer<TValue> |
| 13 | +{ |
| 14 | + // private readonly Driver _driver; |
| 15 | + // private readonly ILogger<Producer<TValue>> _logger; |
| 16 | + // private readonly long _partitionId; |
| 17 | + // private readonly string _sessionId; |
| 18 | + // private readonly ISerializer<TValue> _serializer; |
| 19 | + // |
| 20 | + // private long _seqNum; |
| 21 | + // |
| 22 | + // private readonly ConcurrentQueue<StreamWriteMessage.Types.FromClient> _inFlightMessages; |
| 23 | + // private volatile ProducerStream _stream; |
| 24 | + // |
| 25 | + // internal Producer( |
| 26 | + // ProducerConfig producerConfig, |
| 27 | + // StreamWriteMessage.Types.InitResponse initResponse, |
| 28 | + // ProducerStream stream, |
| 29 | + // ISerializer<TValue> serializer) |
| 30 | + // { |
| 31 | + // _driver = producerConfig.Driver; |
| 32 | + // _stream = stream; |
| 33 | + // _serializer = serializer; |
| 34 | + // _logger = producerConfig.Driver.LoggerFactory.CreateLogger<Producer<TValue>>(); |
| 35 | + // _partitionId = initResponse.PartitionId; |
| 36 | + // _sessionId = initResponse.SessionId; |
| 37 | + // _seqNum = initResponse.LastSeqNo; |
| 38 | + // _inFlightMessages = new ConcurrentQueue<StreamWriteMessage.Types.FromClient>(); |
| 39 | + // } |
| 40 | + |
| 41 | + public Task<SendResult> SendAsync(TValue data) |
| 42 | + { |
| 43 | + throw new NotImplementedException(); |
| 44 | + } |
| 45 | + |
| 46 | + public Task<SendResult> SendAsync(Message<TValue> message) |
| 47 | + { |
| 48 | + throw new NotImplementedException(); |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +public class Message<TValue> |
| 53 | +{ |
| 54 | + public Message(TValue data) |
| 55 | + { |
| 56 | + Data = data; |
| 57 | + } |
| 58 | + |
| 59 | + public DateTime Timestamp { get; set; } |
| 60 | + |
| 61 | + public TValue Data { get; } |
| 62 | + |
| 63 | + public List<Metadata> Metadata { get; } = new(); |
| 64 | +} |
| 65 | + |
| 66 | +public record Metadata(string Key, byte[] Value); |
| 67 | + |
| 68 | +public class SendResult |
| 69 | +{ |
| 70 | + public SendResult(State status) |
| 71 | + { |
| 72 | + State = status; |
| 73 | + } |
| 74 | + |
| 75 | + public State State { get; } |
| 76 | +} |
| 77 | + |
| 78 | +public enum State |
| 79 | +{ |
| 80 | + Written, |
| 81 | + AlreadyWritten |
| 82 | +} |
| 83 | + |
| 84 | +internal enum ProducerState |
| 85 | +{ |
| 86 | + Ready |
| 87 | + // Broken |
| 88 | +} |
0 commit comments