Skip to content
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

Implement named instances support #63

Merged
merged 6 commits into from
Aug 26, 2020
Merged

Implement named instances support #63

merged 6 commits into from
Aug 26, 2020

Conversation

tailhook
Copy link
Contributor

This adds positional argument to connect() and createPool() functions which can be either DSN or an instance name.

This is a part of what's discussed in edgedb/edgedb#1683 other things will follow in the next release.

This also deprecates admin=True parameter and edgedbadmin schema, as
they aren't needed if proper permissions are set up. And were introduced
mainly for command-line tools.

Supersedes #62

Also deprecate `admin: true` and `edgedbadmin:` protocol, as
they aren't needed if proper permissions are set up. And was introduced
mainly for command-line tools.
@tailhook tailhook force-pushed the named_instances branch 9 times, most recently from 7d993be to d9cb1a6 Compare August 21, 2020 14:37
This adds positional argument to `connect()` and `createPool()`
functions which can be either DSN or an instance name.
@@ -9,19 +9,21 @@ API
Connection
==========

.. js:function:: connect(options)
.. js:function:: connect(dsn, options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paul, I don't like breaking the API just yet. I'd do this differently: let's make options to be of type ConnectConfig | string | null.

We can then gradually introduce "instances" - they'll be a separate JS type that we will be able to check with an instanceof - and ban plain objects (currently ConnectConfig)

Copy link
Contributor Author

@tailhook tailhook Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, then you can't set timeout. Or the API would look like:

connect(name_or_dsn_or_options: string | ConnectOptions | null, options: ConnectOptions | null)

(and then throw error if both are objects?) I.e. jQuery-age libraries had a lot of API looking like this, but in 2020...

And then what to do with createPool? This function without options is next to useless.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on the call, let's try:

Support all connect(instanceName), connect(ConnectConfig) and connect(instanceName, ConnectConfig) use cases. The signature will likely look like this:

connect(ConnectConfig | string | null, ConnectConfig | null)

The code will need to validate that only one ConnectConfig is actually passed.

We'll start issuing deprecation warnings once we fully agree on the new instance API and start implementing it.

Copy link
Member

@1st1 1st1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to approach this different for now, essentially without breaking backwards compat (see my only comment for this review). We'll have an opportunity to deprecate/change the API later.

@tailhook
Copy link
Contributor Author

Updated the code. Docs insist on the new signature and mention compatible form as a side note.

@tailhook tailhook closed this Aug 26, 2020
@tailhook tailhook reopened this Aug 26, 2020
// or
await connect({dsn: 'edgedb://localhost'})

But this form is deprecated and will be removed in the future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@1st1 1st1 merged commit ce221bb into master Aug 26, 2020
@1st1 1st1 deleted the named_instances branch August 26, 2020 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants