@@ -4,10 +4,13 @@ module Flagsmith
44 # Config options shared around Engine
55 class Config
66 DEFAULT_API_URL = 'https://edge.api.flagsmith.com/api/v1/'
7+ DEFAULT_REALTIME_API_URL = 'https://realtime.flagsmith.com/'
8+
79 OPTIONS = %i[
810 environment_key api_url custom_headers request_timeout_seconds enable_local_evaluation
911 environment_refresh_interval_seconds retries enable_analytics default_flag_handler
10- offline_mode offline_handler polling_manager_failure_limit logger
12+ offline_mode offline_handler polling_manager_failure_limit
13+ realtime_api_url enable_realtime_updates logger
1114 ] . freeze
1215
1316 # Available Configs
@@ -40,6 +43,9 @@ class Config
4043 # the entire environment, project, flags, etc.
4144 # +polling_manager_failure_limit+ - An integer to control how long to suppress errors in
4245 # the polling manager for local evaluation mode.
46+ # +realtime_api_url+ - Override the realtime api URL to communicate with a
47+ # non-standard realtime endpoint.
48+ # +enable_realtime_updates+ - A boolean to enable realtime updates.
4349 # +logger+ - Pass your logger, default is Logger.new($stdout)
4450 #
4551 attr_reader ( *OPTIONS )
@@ -62,6 +68,10 @@ def offline_mode?
6268 @offline_mode
6369 end
6470
71+ def realtime_mode?
72+ @enable_realtime_updates
73+ end
74+
6575 def environment_flags_url
6676 'flags/'
6777 end
@@ -92,6 +102,9 @@ def build_config(options)
92102 @offline_mode = opts . fetch ( :offline_mode , false )
93103 @offline_handler = opts [ :offline_handler ]
94104 @polling_manager_failure_limit = opts . fetch ( :polling_manager_failure_limit , 10 )
105+ @realtime_api_url = opts . fetch ( :realtime_api_url , Flagsmith ::Config ::DEFAULT_REALTIME_API_URL )
106+ @realtime_api_url << '/' unless @realtime_api_url . end_with? '/'
107+ @enable_realtime_updates = opts . fetch ( :enable_realtime_updates , false )
95108 @logger = options . fetch ( :logger , Logger . new ( $stdout) . tap { |l | l . level = :debug } )
96109 end
97110 # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
0 commit comments