| | | 1 | | using Google.Cloud.PubSub.V1; |
| | | 2 | | |
| | | 3 | | namespace AsyncResponse.Transports.GooglePubSub; |
| | | 4 | | |
| | | 5 | | internal interface IGooglePubSubPublisherClient |
| | | 6 | | { |
| | | 7 | | Task<string> PublishAsync(PubsubMessage message); |
| | | 8 | | Task ShutdownAsync(TimeSpan timeout); |
| | | 9 | | } |
| | | 10 | | |
| | | 11 | | internal sealed class GooglePubSubPublisherClientAdapter(PublisherClient inner) : IGooglePubSubPublisherClient |
| | | 12 | | { |
| | | 13 | | /// <summary>Publishes the supplied message.</summary> |
| | | 14 | | public Task<string> PublishAsync(PubsubMessage message) |
| | | 15 | | => inner.PublishAsync(message); |
| | | 16 | | |
| | | 17 | | /// <summary>Runs the ShutdownAsync operation.</summary> |
| | | 18 | | public Task ShutdownAsync(TimeSpan timeout) |
| | | 19 | | => inner.ShutdownAsync(timeout); |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | internal interface IGooglePubSubSubscriberClient |
| | | 23 | | { |
| | | 24 | | Task StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>> handler); |
| | | 25 | | Task StopAsync(SubscriberClient.ShutdownOptions options, CancellationToken cancellationToken); |
| | | 26 | | } |
| | | 27 | | |
| | 3 | 28 | | internal sealed class GooglePubSubSubscriberClientAdapter(SubscriberClient inner) : IGooglePubSubSubscriberClient |
| | | 29 | | { |
| | | 30 | | /// <summary>Starts this service.</summary> |
| | | 31 | | public Task StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>> handler) |
| | 3 | 32 | | => inner.StartAsync(handler); |
| | | 33 | | |
| | | 34 | | /// <summary>Stops this service.</summary> |
| | | 35 | | public Task StopAsync(SubscriberClient.ShutdownOptions options, CancellationToken cancellationToken) |
| | 3 | 36 | | => inner.StopAsync(options, cancellationToken); |
| | | 37 | | } |