Skip to content

Use endpoint as default connection option (ADR-119) #441

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

surminus
Copy link

This implements ADR-119[1], which specifies the client connection options to update requests to the endpoints implemented as part of ADR-042[2].

The endpoint may be one of the following:

  • a routing policy name (such as main)
  • a nonprod routing policy name (such as nonprod:sandbox)
  • a FQDN such as foo.example.com

The endpoint option is not valid with any of environment, restHost or realtimeHost, but we still intend to support the legacy options.

If the client has been configured to use any of these legacy options, then they should continue to work in the same way, using the same primary and fallback hostnames.

If the client has not been explicitly configured, then the hostnames will change to the new ably.net domain when the package is upgraded.

Notes on implementation

This is still a work in progress, I'm opening a PR to allow tests to run.

I've tried to change as little as possible, but we already had a method named endpoint so I've switched that to uri (open to better naming suggestions).

I haven't yet added any explicit tests for using endpoint, and tried to limit changes to the existing to the updated hostname.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3428810778/ADR-119+ClientOptions+for+new+DNS+structure
[2] https://ably.atlassian.net/wiki/spaces/ENG/pages/1791754276/ADR-042+DNS+Restructure

Rubocop needs to be configured for this repository, but is currently
quite a bit of work to get it up to standards[1].

While we get to actually enabling Rubocop, it would be nice to be
explicit that it's not something that my editor should bother me with
when working in this repository.

[1] #139
@github-actions github-actions bot temporarily deployed to staging/pull/441/features January 31, 2025 13:15 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs January 31, 2025 13:16 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from d3e56fb to cc7ab95 Compare January 31, 2025 13:28
@github-actions github-actions bot temporarily deployed to staging/pull/441/features January 31, 2025 13:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs January 31, 2025 13:29 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from cc7ab95 to 7d81b61 Compare February 10, 2025 16:38
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 10, 2025 16:39 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 10, 2025 16:39 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from 7d81b61 to bae5bc3 Compare February 10, 2025 17:04
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 10, 2025 17:05 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 10, 2025 17:05 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from bae5bc3 to 4f76a08 Compare February 10, 2025 17:14
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 10, 2025 17:15 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 10, 2025 17:15 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 10, 2025 17:24 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 10, 2025 17:24 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 11, 2025 10:47 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 11, 2025 10:47 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 11, 2025 10:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 11, 2025 10:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 11, 2025 18:23 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 11, 2025 18:23 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from 8578bee to 491a6a6 Compare February 12, 2025 10:27
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 12, 2025 10:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 12, 2025 10:28 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from 491a6a6 to 1cda434 Compare February 12, 2025 10:28
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs February 12, 2025 10:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/features February 12, 2025 10:29 Inactive
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian left a comment

Choose a reason for hiding this comment

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

Thanks @surminus! A few thoughts from an initial review:

  • do you think you could split out the rename of the endpoint method into a separate, preceding commit? it would help with readability if the functional changes and the refactor were separate
  • please could you add comments to mention the spec points (see Updates for ADR-119: updated ClientOptions for new domains specification#213) that the new code relates to?
  • please could you add tests for the new functionality (i.e. for the endpoint client option), again with reference to the relevant spec points
  • where spec points have been removed or replaced (e.g. RTN17b, a bunch under RSC15) please could you update the corresponding code and tests that make reference to these spec points?

@surminus
Copy link
Author

@lawrence-forooghian thanks for the review, these all seem like good points, I will try to get to them in the next week or two!

The `endpoint` naming is going to be used as a client option, so we need
to rename everywhere this is currently used to avoid conflation.
This implements ADR-119[1], which specifies the client connection
options to update requests to the endpoints implemented as part of
ADR-042[2].

The endpoint may be one of the following:

* a routing policy name (such as `main`)
* a nonprod routing policy name (such as `nonprod:sandbox`)
* a FQDN such as `foo.example.com`

The endpoint option is not valid with any of environment, restHost or
realtimeHost, but we still intend to support the legacy options.

If the client has been configured to use any of these legacy options,
then they should continue to work in the same way, using the same
primary and fallback hostnames.

If the client has not been explicitly configured, then the hostnames
will change to the new `ably.net` domain when the package is upgraded.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3428810778/ADR-119+ClientOptions+for+new+DNS+structure
[2] https://ably.atlassian.net/wiki/spaces/ENG/pages/1791754276/ADR-042+DNS+Restructure
The expected result has changed in this test, as per this internal Slack
thread[1].

[1] https://ably-real-time.slack.com/archives/CURL4U2FP/p1733479167314059?thread_ts=1733420816.469159&cid=CURL4U2FP
@surminus surminus force-pushed the laura/endpoint-option branch from 72ccd71 to f8eba18 Compare March 20, 2025 16:26
@github-actions github-actions bot temporarily deployed to staging/pull/441/features March 20, 2025 16:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs March 20, 2025 16:27 Inactive
@surminus
Copy link
Author

@lawrence-forooghian I've broken out the commit for renaming the endpoint method.

RE: tests, even though in my initial comment I said I hadn't added tests, I do seem to have added a new context for using endpoint in the client initializer[1], is this sufficient? Or do we want to include new contexts everywhere we use an environment option? I think really they should just behave the same way so not sure if we're gaining much value from them.

I'm going to look at updating the spec references now.

[1]

context 'endpoint' do
context 'when set without custom fallback hosts configured' do
let(:endpoint) { 'foo' }
let(:client_options) { default_options.merge(endpoint: endpoint) }
let(:default_fallbacks) { %w(a b c d e).map { |id| "#{endpoint}.#{id}.fallback.ably-realtime.com" } }
it 'sets the endpoint attribute' do
expect(subject.endpoint).to eql(endpoint)
end
it 'uses the default fallback hosts (#TBC, see https://github.com/ably/wiki/issues/361)' do
expect(subject.fallback_hosts.sort).to eql(default_fallbacks)
end
end
context 'when set with custom fallback hosts configured' do
let(:endpoint) { 'foo' }
let(:custom_fallbacks) { %w(a b c).map { |id| "#{endpoint}-#{id}.foo.com" } }
let(:client_options) { default_options.merge(endpoint: endpoint, fallback_hosts: custom_fallbacks) }
it 'sets the endpoint attribute' do
expect(subject.endpoint).to eql(endpoint)
end
it 'uses the custom provided fallback hosts (#RSC15a)' do
expect(subject.fallback_hosts.sort).to eql(custom_fallbacks)
end
end
context 'when set with fallback_hosts_use_default' do
let(:endpoint) { 'foo' }
let(:custom_fallbacks) { %w(a b c).map { |id| "#{endpoint}-#{id}.foo.com" } }
let(:default_production_fallbacks) { %w(a b c d e).map { |id| "main.#{id}.fallback.ably-realtime.com" } }
let(:client_options) { default_options.merge(endpoint: endpoint, fallback_hosts_use_default: true) }
it 'sets the endpoint attribute' do
expect(subject.endpoint).to eql(endpoint)
end
it 'uses the production default fallback hosts (#RTN17b)' do
expect(subject.fallback_hosts.sort).to eql(default_production_fallbacks)
end
end
end

@github-actions github-actions bot temporarily deployed to staging/pull/441/features April 3, 2025 10:25 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs April 3, 2025 10:26 Inactive
@surminus
Copy link
Author

surminus commented Apr 3, 2025

@lawrence-forooghian I've updated the specs where they seem relevant, but there weren't actually that many references? It seemed a little inconsistent in the way they were applied. Do I need to also update SPEC.md?

@lawrence-forooghian
Copy link
Collaborator

@surminus as discussed on Slack, please could you make sure that this PR implements / tests the updates to REC1b2 from ably/specification#302? Thanks!

@surminus surminus force-pushed the laura/endpoint-option branch from a54886c to 6fa7260 Compare May 22, 2025 09:53
@github-actions github-actions bot temporarily deployed to staging/pull/441/features May 22, 2025 09:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/441/docs May 22, 2025 09:54 Inactive
@surminus surminus force-pushed the laura/endpoint-option branch from 6fa7260 to c5a9325 Compare May 22, 2025 10:31
@surminus
Copy link
Author

@lawrence-forooghian I've updated the tests and added appropriate annotations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants