-
Notifications
You must be signed in to change notification settings - Fork 0
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: bootstrap and timeout initialization #11
base: main
Are you sure you want to change the base?
Conversation
end | ||
end | ||
|
||
defp update_specs(specs) 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 would expect this to return the updated configs and not just the time, which doesn't seem to be added to the configs that have been updated.
update_specs(response) | ||
{:ok, %{state | last_sync_time: new_time}} | ||
rescue | ||
error -> |
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.
what can happen to cause this? It's a little strange to see a try/rescue in elixir code.
I would actually make it so that update_specs
can't raise.
@@ -41,9 +47,12 @@ defmodule Statsig.Configs do | |||
@impl true | |||
def init(_) do | |||
:ets.new(@table_name, [:named_table, :set, :public]) | |||
initial_state = State.new() | |||
initial_state = case init_from_bootstrap() 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.
nit: this looks like it wasn't formatted.
interval = reload_interval() | ||
%__MODULE__{reload_interval: interval} |
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 kind of prefer the old one.
end | ||
|
||
test "uses bootstrapped gate values" do | ||
{:ok, result} = Statsig.check_gate(%Statsig.User{user_id: "12345"}, "test_numeric_user_id") |
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.
for gates, there's a three way logic here that I'm not sure you intended.
One option is some kind of error occurring, the other is that the result is true or false.
Can you describe how checking a gate can fail? As a user, I'd prefer:
if Statsig.check_gate?(...) do
...
end
@@ -41,9 +47,12 @@ defmodule Statsig.Configs do | |||
@impl true | |||
def init(_) do | |||
:ets.new(@table_name, [:named_table, :set, :public]) | |||
initial_state = State.new() | |||
initial_state = case init_from_bootstrap() 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.
Can you document the spec?
There are two main pieces missing to initialization to make this more robust. We dont want to block application startup because of a) a network request taking too long or b) failure to initialize statsig.
This adds two configuration options:
To address this. Bootstrapping will still attempt to sync from the network