@@ -11,9 +11,11 @@ Package courier contains the client that can be used to interact with the courie
1111## Index
1212
1313- [ Variables] ( #variables )
14+ - [ func ClientIDFromContext\( ctx context.Context\) string] ( #ClientIDFromContext )
1415- [ func ExponentialStartStrategy\( ctx context.Context, c interface\{ Start\(\) error \} , opts ...StartOption\) ] ( #ExponentialStartStrategy )
1516- [ func Version\(\) string] ( #Version )
1617- [ func WaitForConnection\( c ConnectionInformer, waitFor time.Duration, tick time.Duration\) bool] ( #WaitForConnection )
18+ - [ func WithClientIDCallback\( ctx context.Context, cb ClientIDCallback\) context.Context] ( #WithClientIDCallback )
1719- [ type Client] ( #Client )
1820 - [ func NewClient\( opts ...ClientOption\) \(\* Client, error\) ] ( #NewClient )
1921 - [ func \( c \* Client\) AckTimeout\(\) time.Duration] ( #Client.AckTimeout )
@@ -34,6 +36,7 @@ Package courier contains the client that can be used to interact with the courie
3436 - [ func \( c \* Client\) UseSubscriberMiddleware\( mwf ...SubscriberMiddlewareFunc\) ] ( #Client.UseSubscriberMiddleware )
3537 - [ func \( c \* Client\) UseUnsubscriberMiddleware\( mwf ...UnsubscriberMiddlewareFunc\) ] ( #Client.UseUnsubscriberMiddleware )
3638 - [ func \( c \* Client\) WriteTimeout\(\) time.Duration] ( #Client.WriteTimeout )
39+ - [ type ClientIDCallback] ( #ClientIDCallback )
3740- [ type ClientInfoEmitter] ( #ClientInfoEmitter )
3841- [ type ClientInfoEmitterConfig] ( #ClientInfoEmitterConfig )
3942- [ type ClientMeta] ( #ClientMeta )
@@ -164,6 +167,15 @@ This is useful when working with shared subscriptions and multiple connections c
164167var UseMultiConnectionMode = multiConnMode{}
165168```
166169
170+ <a name =" ClientIDFromContext " ></a >
171+ ## func [ ClientIDFromContext] ( https://github.com/gojek/courier-go/blob/main/context.go#L29 )
172+
173+ ``` go
174+ func ClientIDFromContext (ctx context .Context ) string
175+ ```
176+
177+ ClientIDFromContext returns the client ID from the context. This is available in subscribe callbacks to identify which MQTT connection received the message.
178+
167179<a name="ExponentialStartStrategy"></a>
168180## func [ExponentialStartStrategy](https:// github.com/gojek/courier-go/blob/main/exp_starter.go#L32)
169181
@@ -191,6 +203,15 @@ func WaitForConnection(c ConnectionInformer, waitFor time.Duration, tick time.Du
191203
192204WaitForConnection checks if the Client is connected, it calls ConnectionInformer.IsConnected after every tick and waitFor is the maximum duration it can block. Returns true only when ConnectionInformer.IsConnected returns true
193205
206+ <a name="WithClientIDCallback"></a>
207+ ## func [WithClientIDCallback](https:// github.com/gojek/courier-go/blob/main/context.go#L13)
208+
209+ ```go
210+ func WithClientIDCallback(ctx context.Context, cb ClientIDCallback) context.Context
211+ ```
212+
213+ WithClientIDCallback returns a context with the callback that will receive the client ID of the underlying MQTT client used for an operation.
214+
194215<a name="Client"></a>
195216## type [Client](https:// github.com/gojek/courier-go/blob/main/client.go#L22-L46)
196217
@@ -423,6 +444,15 @@ func (c *Client) WriteTimeout() time.Duration
423444
424445WriteTimeout returns the write timeout duration configured for the client
425446
447+ <a name="ClientIDCallback"></a>
448+ ## type [ClientIDCallback](https:// github.com/gojek/courier-go/blob/main/context.go#L9)
449+
450+ ClientIDCallback is a function that receives the client ID used for an operation.
451+
452+ ```go
453+ type ClientIDCallback func(clientID string)
454+ ```
455+
426456<a name="ClientInfoEmitter"></a>
427457## type [ClientInfoEmitter](https:// github.com/gojek/courier-go/blob/main/metrics.go#L17-L19)
428458
@@ -880,7 +910,7 @@ type Logger interface {
880910```
881911
882912<a name =" MQTTClientInfo " ></a >
883- ## type [ MQTTClientInfo] ( https://github.com/gojek/courier-go/blob/main/client_telemetry.go#L14-L25 )
913+ ## type [ MQTTClientInfo] ( https://github.com/gojek/courier-go/blob/main/client_telemetry.go#L15-L26 )
884914
885915MQTTClientInfo contains information about the internal MQTT client
886916
0 commit comments