Class: Fly::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/fly-ruby/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
35
36
# File 'lib/fly-ruby/configuration.rb', line 27

def initialize
  self.primary_region = ENV["PRIMARY_REGION"]
  self.current_region = ENV["FLY_REGION"]
  self.replay_http_methods = ["POST", "PUT", "PATCH", "DELETE"]
  self.database_url_env_var = "DATABASE_URL"
  self.database_host_env_var = "DATABASE_HOST"
  self.database_port_env_var = "DATABASE_PORT"
  self.replay_threshold_cookie = "fly-replay-threshold"
  self.replay_threshold_in_seconds = 5
end

Instance Attribute Details

#current_regionObject

Set the region where this instance of the application is deployed



4
5
6
# File 'lib/fly-ruby/configuration.rb', line 4

def current_region
  @current_region
end

#database_host_env_varObject

Returns the value of attribute database_host_env_var.



16
17
18
# File 'lib/fly-ruby/configuration.rb', line 16

def database_host_env_var
  @database_host_env_var
end

#database_port_env_varObject

Returns the value of attribute database_port_env_var.



17
18
19
# File 'lib/fly-ruby/configuration.rb', line 17

def database_port_env_var
  @database_port_env_var
end

#database_url_env_varObject

Environment variables related to the database connection. These get by this middleware in secondary regions, so they must be interpolated rather than defined directly in the configuration.



15
16
17
# File 'lib/fly-ruby/configuration.rb', line 15

def database_url_env_var
  @database_url_env_var
end

#primary_regionObject

Set the region where the primary database lives, i.e “ams”



7
8
9
# File 'lib/fly-ruby/configuration.rb', line 7

def primary_region
  @primary_region
end

#replay_http_methodsObject

Automatically replay these HTTP methods in the primary region



10
11
12
# File 'lib/fly-ruby/configuration.rb', line 10

def replay_http_methods
  @replay_http_methods
end

Cookie written and read by this middleware storing a UNIX timestamp. Requests arriving before this timestamp will be replayed in the primary region.



21
22
23
# File 'lib/fly-ruby/configuration.rb', line 21

def replay_threshold_cookie
  @replay_threshold_cookie
end

#replay_threshold_in_secondsObject

How long, in seconds, should all requests from the same client be replayed in the primary region after a successful write replay



25
26
27
# File 'lib/fly-ruby/configuration.rb', line 25

def replay_threshold_in_seconds
  @replay_threshold_in_seconds
end

Instance Method Details

#database_urlObject



38
39
40
# File 'lib/fly-ruby/configuration.rb', line 38

def database_url
  ENV[database_url_env_var]
end

#eligible_for_activation?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fly-ruby/configuration.rb', line 42

def eligible_for_activation?
  database_url && primary_region && current_region
end