# Hybrid Dependency Provider / Entrypoint

**URL:** <https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255>\
**Category:** googlegroup\
**Created:** [May 3, 2018, 3:13pm UTC](https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255 "2018-05-03T15:13:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Windridge](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Jonathan\_Windridge](https://discourse.nameko.io/u/Jonathan_Windridge)\
**Post date:** [May 3, 2018, 3:13pm UTC](https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255/1 "2018-05-03T15:13:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![David\_Szotten](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/david_szotten/32/6_2.png) [@David\_Szotten](https://discourse.nameko.io/u/David_Szotten)\
**Post date:** [May 3, 2018, 7:15pm UTC](https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255/2 "2018-05-03T19:15:30Z")

</div>

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\](https://github.com/nameko/nameko/blob/master/nameko/web/websocket.py#L233%5C))  
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

---

<div class="post-metadata">

**Author:** ![Jonathan\_Windridge](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Jonathan\_Windridge](https://discourse.nameko.io/u/Jonathan_Windridge)\
**Post date:** [May 3, 2018, 8:00pm UTC](https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255/3 "2018-05-03T20:00:55Z")

</div>

Hi David,

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

Kind regards,

Jonathan

---

<div class="post-metadata">

**Author:** ![David\_Szotten](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/david_szotten/32/6_2.png) [@David\_Szotten](https://discourse.nameko.io/u/David_Szotten)\
**Post date:** [May 3, 2018, 8:11pm UTC](https://discourse.nameko.io/t/hybrid-dependency-provider-entrypoint/255/4 "2018-05-03T20:11:13Z")

</div>

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
