Hybrid Dependency Provider / Entrypoint

Hi,

I'm writing a Nameko gateway service that acts as a wrapper around a
websocket connection - the service needs to be able to manipulate the
websocket connection in RPC methods (e.g. to update channel subscriptions),
as well as having methods triggered in response to websocket messages (in
order to broadcast events across the rest of the system). While writing
either an Entrypoint (to trigger service methods) or Dependency Provider
(to enable interaction within service methods) is straightforward, I'm not
sure of the best way forward to implement both on the same underlying
connection.

Is there an established pattern for this sort of interaction? Is the best
pattern perhaps to implement the websocket connection itself as a
Extension, and then somehow use it as a sub-extension singleton in separate
Entrypoint & Dependency Provider implementations?

Thanks in advance,

Jonathan

This is already how the bundled websocket rpc and "hub" (for interacting
with existing connections) work. as you can see
[here](https://github.com/nameko/nameko/blob/master/nameko/web/websocket.py#L233\)
they share a common "shared extension"

Best,
David

···

On Thursday, 3 May 2018 16:13:26 UTC+1, jonathan....@gmail.com wrote:

Hi,

I'm writing a Nameko gateway service that acts as a wrapper around a
websocket connection - the service needs to be able to manipulate the
websocket connection in RPC methods (e.g. to update channel subscriptions),
as well as having methods triggered in response to websocket messages (in
order to broadcast events across the rest of the system). While writing
either an Entrypoint (to trigger service methods) or Dependency Provider
(to enable interaction within service methods) is straightforward, I'm not
sure of the best way forward to implement both on the same underlying
connection.

Is there an established pattern for this sort of interaction? Is the best
pattern perhaps to implement the websocket connection itself as a
Extension, and then somehow use it as a sub-extension singleton in separate
Entrypoint & Dependency Provider implementations?

Thanks in advance,

Jonathan

Hi David,

Thankyou very much for the quick reply - that pattern was indeed exactly what I was looking for!

Kind regards,

Jonathan

Great, glad to help

d

···

On Thursday, 3 May 2018 21:00:55 UTC+1, jonathan....@gmail.com wrote:

Hi David,

Thankyou very much for the quick reply - that pattern was indeed exactly
what I was looking for!

Kind regards,

Jonathan