senecajs / seneca-transport

Seneca micro-services message transport over TCP and HTTP.
MIT License
63 stars 45 forks source link

use plugins overwrite configured transport #55

Closed dvilchez closed 8 years ago

dvilchez commented 8 years ago

I want to use rabbitmq as transport and I am using the web bindings configured in the plugins, my first try was: seneca.use('rabbitmq-transport').use('user').use('auth').client( {type:'rabbitmq'} ) seneca doesn't use rabbitmq queues for communication, it keeps using the default transport.

second try: seneca.use('rabbitmq-transport').client( {type:'rabbitmq'} ) and implements my own routes. seneca use rabbitmq for communication, seneca-auth fails with this error: Cannot read property 'name' of undefined at /Users/dvilchez/workspace/ticketpoint/lib/user-management/node_modules/seneca auth/lib/auth.js:185:22

then I realised that seneca-auth is very coupled with express since it creates the session cookie and all this stuff, I thought I could use seneca-auth in my web server and seneca-user in my separate microservice, but seneca-auth has a dependency with seneca-user.

What am I missing? Is all this really oriented to microservices?

rjrodger commented 8 years ago

You're right - seneca-auth is for express middleware style integration - it has to know how talk HTTP. seneca-user is different - it's just business logic. seneca-auth uses seneca-user to perform the actual logins, password verifications etc.

An example configuration might be: web server talking to a separate user service.

Web server: seneca().use('auth').use('rabbitmq-transport').client( {type:'rabbitmq'} ) as role:user patterns are not defined locally, they will be sent out over the bus

user service (separate process): seneca().use('user').use('rabbitmq-transport').listen( {type:'rabbitmq'} )

In production, you'll probably want to use a pin:'role:user' to ensure a separate topic for user messages.

For non express servers, say hapi, you'll need to use the seneca-user patterns directly. There is however a hapi integration in the works /cc @mcdonnelldean @geek

Hope this makes sense?

mcdonnelldean commented 8 years ago

seneca-web now supports hapi.