public ReactiveRpcClient(ILogger <ReactiveRpcClient> logger, IGoogleCloudPubSubClient googleCloudPubSubClient) { _logger = logger; _googleCloudPubSubClient = googleCloudPubSubClient; // initialize cache _remoteTasksCache = new SourceCache <RemoteTask, Guid>(remoteTask => remoteTask.id); // subscribe to task id events _remoteTasksCache.Connect() // .Filter(remoteTask => remoteTask.id == remoteTask1.id) .OnItemAdded(remoteTask => { Console.WriteLine($"Added remoteTask: {remoteTask.name}"); }) .OnItemUpdated((current, previous) => { Console.WriteLine($"Updated remoteTask: {current.name}, completed = {current.completed}"); if (current.completed) { this._remoteTasksCache.Remove(current); } }) .OnItemRemoved(remoteTask => { Console.WriteLine($"Removed remoteTask: {remoteTask.name}"); }) .Subscribe(); }
// public PullingJob(IServiceProvider serviceProvider) // { // _serviceProvider = serviceProvider; // _logger = _serviceProvider.GetService<ILoggerFactory>().CreateLogger<PullingJob>(); // } public PublishingJob(ILogger <PublishingJob> logger, IGoogleCloudPubSubClient googleCloudPubSubClient, IReactiveRpcClient reactiveRpcClient) { _logger = logger; _googleCloudPubSubClient = googleCloudPubSubClient; _remoteTasksCache = reactiveRpcClient.RemoteTasksCache; }