Hybrid Dependency Provider / Entrypoint

31 views
Skip to first unread message

jonathan....@gmail.com

unread,
May 3, 2018, 11:13:26 AM5/3/18
to nameko-dev
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

David Szotten

unread,
May 3, 2018, 3:15:30 PM5/3/18
to nameko-dev
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

jonathan....@gmail.com

unread,
May 3, 2018, 4:00:55 PM5/3/18
to nameko-dev
Hi David,

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

Kind regards,

Jonathan

David Szotten

unread,
May 3, 2018, 4:11:13 PM5/3/18
to nameko-dev
Great, glad to help

d
Reply all
Reply to author
Forward
0 new messages