コード例 #1
0
        /// <summary>
        /// Constructor. Initializes the <see cref="_consumer"/> instance.
        /// </summary>
        /// <param name="consumerFactory">
        /// A <see cref="IKafkaConsumerFactory{TKey,TValue}"/> using <see cref="SubmitKey"/> keys and <see cref="string"/> values</param>
        /// <param name="diffGenerator">A <see cref="IDiffGenerator"/>. Used to generate diffs from left and right values.</param>
        /// <param name="diffRepository">A <see cref="IDiffRepository"/>. Used to persist <see cref="DiffRecord"/>s.</param>
        /// <param name="keyDeserializer">A <see cref="IDeserializer{T}"/>, used to deserialize <see cref="SubmitKey"/>s.</param>
        /// <param name="valueDeserializer">A <see cref="IDeserializer{T}"/>, used to deserialize <see cref="string"/> values.</param>
        /// <param name="logger">A <see cref="ILogger{T}"/> for this class.</param>
        /// <param name="bootstrapServer">Kafka server. Overrides default 'localhost:9092' value.</param>
        public TopicListener(
            IKafkaConsumerFactory <SubmitKey, string> consumerFactory,
            IDiffGenerator diffGenerator,
            IDiffRepository diffRepository,
            IDeserializer <SubmitKey> keyDeserializer,
            IDeserializer <string> valueDeserializer,
            ILogger <TopicListener> logger,
            string bootstrapServer)
        {
            _diffGenerator  = diffGenerator;
            _diffRepository = diffRepository;
            _logger         = logger;

            // TODO: not sure it must be a ConcurrentDictionary here, but keeping it just in case
            var config = new ConcurrentDictionary <string, object>(Config);

            if (!string.IsNullOrWhiteSpace(bootstrapServer))
            {
                config["bootstrap.servers"] = bootstrapServer;
            }

            _logger.Info($"config[bootstrap.servers] = {config["bootstrap.servers"]}.");
            _consumer = consumerFactory.Create(config, keyDeserializer, valueDeserializer);
            _consumer.Assign(new List <TopicPartitionOffset> {
                new TopicPartitionOffset(Topic, 0, 0)
            });
        }
コード例 #2
0
 public UpdateRecordImpl(
     int nodeId,
     IDiffRepository <TUserId, TKey, TDb, TNew> diffRepository)
 {
     this.nodeId         = nodeId;
     this.diffRepository = diffRepository;
 }
コード例 #3
0
 public DiffDsl(
     IDiffRepository <TUserId, TKey, TDb, TNew> diffRepository,
     bool immutable)
 {
     this.diffRepository = diffRepository;
     this.immutable      = immutable;
 }
コード例 #4
0
        public DiffMvcController(IDiffRepository diffRepository)
        {
            if (diffRepository == null)
            {
                throw new ArgumentNullException(nameof(diffRepository));
            }

            _diffRepository = diffRepository;
        }
コード例 #5
0
        public DiffService(IDiffRepository diffRepository)
        {
            if (diffRepository == null)
            {
                throw new ArgumentNullException(nameof(diffRepository));
            }

            _diffRepository = diffRepository;
        }
コード例 #6
0
 public RootNode(
     int nodeId,
     bool immutable,
     IDiffRepository <TUserId, TKey, TDb, TNew> diffRepository,
     List <IUpdateValue <TNew, TDb, TKey> > updateValues) : base(nodeId)
 {
     this.diffRepository = diffRepository;
     this.immutable      = immutable;
     this.updateValues   = updateValues;
 }
コード例 #7
0
        /// <summary>
        /// Dependency Injection Container used for decoupling (testability etc.)
        /// </summary>
        /// <param name="diffRepository">Constructor injected repository.</param>
        public DiffController(IDiffRepository diffRepository)
        {
            if (diffRepository == null)
            {
                throw new ArgumentNullException(nameof(diffRepository));
            }

            _diffRepository = diffRepository;
            _diffService    = new DiffService(_diffRepository);
            _modelFactory   = new ModelFactory();
        }
コード例 #8
0
 public DiffController(
     ILogger <DiffController> logger,
     IDiffRepository diffRepository,
     IInputRepository inputRepository,
     IMapper mapper,
     IRabbitMQEventBus eventBus
     )
 {
     _logger          = logger;
     _diffRepository  = diffRepository;
     _inputRepository = inputRepository;
     _mapper          = mapper;
     _eventBus        = eventBus;
 }
コード例 #9
0
 public UpdateManyToOne(
     int nodeId,
     bool immutable,
     Func <TNew, TNewProp> newProp,
     Expression <Func <TDbValue, TDbProp> > dbValue,
     IEnumerable <IUpdateValue <TNewProp, TDbProp, TChildKey> > childValues,
     IDiffRepository <TUserId, TChildKey, TDbProp, TNewProp> diffRepository) : base(nodeId)
 {
     this.immutable      = immutable;
     this.newProp        = newProp;
     this.dbValue        = dbValue.Compile();
     this.setDbValue     = ExpressionUtils.CreateSetter(dbValue);
     this.childValues    = childValues;
     this.diffRepository = diffRepository;
 }
コード例 #10
0
        /// <summary>
        /// Controller. Fetches injected instances and starts kafka worker thread.
        /// </summary>
        /// <param name="topicListener">A <see cref="ITopicListener"/>, which will process messages from the listened topic.</param>
        /// <param name="diffRepository">A <see cref="IDiffRepository"/>, used to store the generated <see cref="DiffRecord"/>.</param>
        public DiffController(
            ITopicListener topicListener,
            IDiffRepository diffRepository)
            : base("v1/diff")
        {
            _topicListener  = topicListener;
            _diffRepository = diffRepository;

            Get("{id}", args =>
            {
                Guid id = args.id;
                return(Response.AsJson(GetDiff(id).Body, GetDiff(id).StatusCode));
            });

            StartWorker();
        }
コード例 #11
0
 public UpdateManyToMany(
     int nodeId,
     bool immutable,
     Func <TNewProp, TChildKey> newPropKey,
     Func <TNew, IEnumerable <TNewProp> > newProp,
     Func <TDbValue, List <TDbProp> > dbValue,
     IEnumerable <IUpdateValue <TNewProp, TDbProp, TChildKey> > childValues,
     Action <TDbProp, TDbValue> setParent,
     IDiffRepository <TUserId, TChildKey, TDbProp, TNewProp> diffRepository) : base(nodeId)
 {
     this.immutable      = immutable;
     this.newProp        = newProp;
     this.dbValue        = dbValue;
     this.childValues    = childValues;
     this.diffRepository = diffRepository;
     this.newPropKey     = newPropKey;
     this.setParent      = setParent;
 }
コード例 #12
0
 public DiffService(IDiffRepository diffRepository)
 {
     _diffReository = diffRepository;
 }
コード例 #13
0
 public DiffService(IDiffRepository diffRepository)
 {
     this.diffRepository = diffRepository;
 }
コード例 #14
0
 public DiffCommandHandler(IDiffRepository repository)
 {
     _repository = repository;
 }
コード例 #15
0
 public PushLeftJsonCommandHandler(IDiffRepository diffRepository)
 {
     _diffRepository = diffRepository;
 }
コード例 #16
0
 public DiffDomainService(IDiffRepository diffRepository)
 {
     _diffRepository = diffRepository;
 }
コード例 #17
0
ファイル: DiffAppService.cs プロジェクト: SacuL/DifferProject
 public DiffAppService(IMapper mapper, IDiffRepository diffRepository, IDiffDomainService diffDomainService)
 {
     _mapper            = mapper;
     _diffRepository    = diffRepository;
     _diffDomainService = diffDomainService;
 }