-
Notifications
You must be signed in to change notification settings - Fork 175
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
feat: use tenants from external source #1967
Conversation
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
73820fd
to
04802ce
Compare
04802ce
to
f011ea0
Compare
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.
Looks good to me
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.
Looks good, left some nits!
{:noreply, %{state | load_successful?: true}} | ||
|
||
{:error, :unreachable} -> | ||
Process.send_after(self(), :retry_initialization, 500) |
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.
nit: need to add a :backoff
here perhaps
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'm not sure I want to. This is called only at startup and normal operations are not working (including serving existing shapes) until this call resolves, so we probably want to hammer the API
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.
It's just that, unless it fails because of some transitory issue, it will almost definitely fail because of a configuration issue/mismatch between the API and Electric, and it will keep erroring every 500ms until we manually fix it. The backoff would ensure that if it's a transitory problem it resolves quickly, and if it is not it doesn't needlessly spam the API since our manual fixes are going to happen in the order of minutes hours or days
do: String.replace(string, "%{instance_id}", to_string(instance_id)) | ||
|
||
@spec collect_ops(Enumerable.t()) :: {map(), map()} | ||
defp collect_ops(ops) do |
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 thought we had written an elixir client (?) which we could reuse - if not ignore me!
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.
https://github.com/electric-sql/electric/tree/main/packages/elixir-client not sure if we published it
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.
@icehaunter can you elaborate a bit more on
I read this as: if electric is briefly unavailable and misses an update to some of the tenants it hosts, it will drop all tenants info. Why is that and why can't we do better? |
It won't. What @icehaunter meant is that tenants may have been added and/or deleted while Electric was down. On restart, Electric will get these updates from the control plane. For each tenant that was deleted, Electric will remove the tenant's shape data from disk (remains to be implemented). For each tenant that was added, Electric will create that tenant. |
end | ||
end) | ||
|
||
Enum.reduce(to_add, state, fn %{"id" => tenant_id, "connection_uri" => connection_url}, |
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.
@icehaunter this should be "connection_url" => connection_url
- we don't have a way to rename things within the shape currently, could fix this and if possible add a test please?
Allows configuring the external source to pull the tenant information from. External source is expected to be an Electric instance.
Notable changes:
Closes #1961