Subscriptions manager
Subscriptions Manager.
Dev notes:
There should be 2 different "types" of subscriptions involved: 1. OneWay Subscription: the server streams events to the client, which handles them. 2. TwoWay Subscription: the server streams events to the client, which handles them and tells back the server which events to consider acknowledged and which ones not.
In both cases, there should be some mechanism for the client to cancel the gRPC call. If this can be controlled by the user of the library, this means that the channel (or the stub) must be reachable from inside the thread. This shouldn't be a problem, since both grpc channels and stubs should be thread-safe: https://github.com/grpc/grpc/issues/9320
In both cases, the library's user must control over what he can do with an event, probably by providing a callback to invoke within the thread (streaming) loop.
In case of the TwoWay Subscription, we could consider instructing the library's user to raise a specific Exception carrying the information to complete the Nack request, or provide a default mechanism in case of different exceptions.
SubscriptionsManager
A Subscription Manager.
Source code in src/eventstore_grpc/subscriptions/subscriptions_manager.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
register(subscription, id_=None)
Registers a subscription to the registry.
Source code in src/eventstore_grpc/subscriptions/subscriptions_manager.py
unsubscribe(stream_name, timeout=5)
Unsubscribes from a stream.