-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed client creation interface #25
Conversation
Actually I'm thinking we can get rid of the convenience function completely to make things even simpler. I like how the postgres client does it. const { Client } = require('pg')
const client = new Client()
await client.connect() Which would look like this for us: const { MessageBus } = require('dbus-next');
let bus = MessageBus();
// calling connect is optional, but there is a use case to wait for a connection
await bus.connect(); What do you think about that? Also we should default to the session bus and have an enum for the bus type. |
Do you mean this would cause the first call on the bus to first wait for the connection? |
I suppose we'd put our options in the MessageBus constructor? Could you elaborate how you think this should look? |
Yes, this happens anyway though. The connection is complete after the "Hello" method is called on the org.freedesktop.DBus interface to give us a unique name. We buffer any messages before that time and send them in a batch after connection is complete. The bus will connect in the constructor, but awaiting a connection just makes it more explicit. Right now, the bus has a "connect" event for that purpose, but I think awaiting is better.
Yeah something like let bus = MessageBus({ busType: BUS_TYPE_SYSTEM, authMethods: ['ANONYMOUS'] }); |
I agree, it's much clearer to the user
I do think we need support for custom bus URIs (because I'm using it :) ), so perhaps this would be better: let localBus = MessageBus({ bus: BUS_SYSTEM, authMethods: ['ANONYMOUS'] });
let remoteBus = MessageBus({ bus: "tcp:host=remote_host,port=1234", authMethods: ['ANONYMOUS'] }); I think |
* `tcp:host=<HOST>,port=<PORT>` | ||
* `unix:path=<PATH>` | ||
* `unixexec:path=<PATH>,arg1=<ARG>,arg2=<ARG>,argN=<ARG>` | ||
* @param {object} [options.authMethods] - array of authentication methods, which are attempted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to document this because I think I want to change it to pass authenticator classes instead of strings.
Practically, the difference is how the address is found. There is a different way of finding the address per type and that's what's being expressed by the
In general, the In your case, you should be doing this to indicate the address:
|
Taking a look at it again, I think this change might be a bit too much of a change for the benefit. Maybe we can revisit it later. |
Replaced
dbus.systemBus()
anddbus.sessionBus()
withdbus.connect({bus: "system"})
anddbus.connect({bus: "session"})
, respectively, as discussed in #23