Skip to content
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

Update to v2 #67

Merged
merged 70 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
658c4ec
Work in progress on ruby v2 refactoring
jkodumal Jun 30, 2016
66d9378
Work in progress on v1 refactoring
jkodumal Jul 6, 2016
960f08a
Fix syntax error
jkodumal Jul 6, 2016
aeabe5f
Fix polling processor ctor
jkodumal Jul 6, 2016
18e7d04
Update imports, add create_worker to EventProcessor, update toggle an…
jkodumal Jul 6, 2016
1001299
Assign res in Event processor
jkodumal Jul 6, 2016
c2df040
Wait for initialization
jkodumal Jul 6, 2016
938573c
Fix syntax error in initializer
jkodumal Jul 6, 2016
e18e27c
Use correct floating point literal syntax
jkodumal Jul 6, 2016
aae8176
offline -> offline?
jkodumal Jul 6, 2016
e9d22da
Fix typo in stream initialization
jkodumal Jul 6, 2016
87a3302
Rescue and log timeout exception
jkodumal Jul 6, 2016
48a5609
Improve debug output in stream
jkodumal Jul 6, 2016
a373bc0
Add debug logging for event enqueuing
jkodumal Jul 6, 2016
2e3e6d9
Debug output for evaluation
jkodumal Jul 6, 2016
e61a05e
More debug output from streaming connection
jkodumal Jul 6, 2016
e4d0a48
Debug output for polling update processor
jkodumal Jul 6, 2016
99645f0
Fix typo in polling processor initialization
jkodumal Jul 6, 2016
771c42e
Import thread package
jkodumal Jul 6, 2016
8b5bc52
More debug output for polling
jkodumal Jul 6, 2016
c50b832
Debug output for requestor
jkodumal Jul 6, 2016
a8da405
Debug the sleep time in polling processor
jkodumal Jul 6, 2016
2264d0c
Clean up feature store definition
jkodumal Jul 6, 2016
1106ff3
Improve debug output
jkodumal Jul 6, 2016
79bd925
More debug output changes
jkodumal Jul 6, 2016
314c674
Remove more debugging
jkodumal Jul 6, 2016
c903e66
Fix endpoint for v1
jkodumal Jul 6, 2016
13f041e
Move evaluation methods into a separate sub-module
jkodumal Jul 6, 2016
dbad74f
Move evaluation sub-module
jkodumal Jul 6, 2016
8f9c213
First cut at v2 evaluation
jkodumal Jul 7, 2016
2571e51
Symbolize event names
jkodumal Jul 7, 2016
4753b2a
Fix syntax error
jkodumal Jul 7, 2016
8380579
Add each to iterator syntax
jkodumal Jul 7, 2016
4f24dcc
Remove references to obsolete private methods
jkodumal Jul 7, 2016
9ef0b60
Pass the correct store
jkodumal Jul 7, 2016
8309254
feature -> flag
jkodumal Jul 7, 2016
2b0969a
r -> rule
jkodumal Jul 7, 2016
e5b1dad
Add the exception backtrace to debug output
jkodumal Jul 7, 2016
a76d93b
Fix builtin lookup
jkodumal Jul 8, 2016
663fbc5
Fix prereq evaluation
jkodumal Jul 8, 2016
8a5f174
Return the correct off variation
jkodumal Jul 8, 2016
4ccf97a
Debug output for off variation
jkodumal Jul 8, 2016
ff44f14
Fix attribute name for offVariation
jkodumal Jul 8, 2016
f94046c
Fix flag key lookup
jkodumal Jul 8, 2016
9f34b98
Don't send flag request event in the internal evaluation method
jkodumal Jul 8, 2016
6c6db75
Debug output for evaluation
jkodumal Jul 8, 2016
ff08368
More debug output for evaluation
jkodumal Jul 8, 2016
76bb162
More debug output
jkodumal Jul 8, 2016
4aaebe5
More debug logging
jkodumal Jul 8, 2016
20032e2
Symbolize attribute
jkodumal Jul 8, 2016
1e91313
Scope reference to operators
jkodumal Jul 8, 2016
b41c912
Inline operators
jkodumal Jul 8, 2016
8fd7a73
move and rename operators
jkodumal Jul 8, 2016
45b2658
Handle unsupported operators
jkodumal Jul 8, 2016
3ccdd86
Remove operators file
jkodumal Jul 8, 2016
a70cfa5
Debug operators
jkodumal Jul 8, 2016
f6a4533
Reverse arguments for matches operator
jkodumal Jul 8, 2016
7910ca7
Change implementations of before and after to handle mixed strings / …
jkodumal Jul 8, 2016
bd45ba5
Fix units for date time conversion
jkodumal Jul 8, 2016
53ee4fa
Handle invalid date strings
jkodumal Jul 8, 2016
50e12d2
A more correct approach to getting epoch millis?
jkodumal Jul 8, 2016
10f8988
Simplify eval_internal and fix prerequisite evaluation
jkodumal Jul 8, 2016
69aa7c0
Don't send a default value for prerequisite evaluation
jkodumal Jul 8, 2016
09881cb
Fix control flow for failed prerequisites. Check if the store does no…
jkodumal Jul 8, 2016
f400b8f
Don't use http persistent for events
jkodumal Jul 8, 2016
ff36fd3
Change faraday client initialization
jkodumal Jul 8, 2016
eccf3c1
Latest features -> latest flags
jkodumal Jul 12, 2016
6aaab91
Send the user in the null toggle case
jkodumal Jul 12, 2016
e639f37
Get tests back up to baseline
jkodumal Jul 19, 2016
acd226a
Remove duplicated operator
jkodumal Jul 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ldclient-rb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "net-http-persistent", "~> 2.9"
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0.0"
spec.add_runtime_dependency "hashdiff", "~> 0.2"
spec.add_runtime_dependency "ld-celluloid-eventsource", "~> 0.4"
spec.add_runtime_dependency "ld-celluloid-eventsource", "~> 0.4"
spec.add_runtime_dependency "waitutil", "0.2"
end
8 changes: 6 additions & 2 deletions lib/ldclient-rb.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require "ldclient-rb/version"
require "ldclient-rb/settings"
require "ldclient-rb/evaluation"
require "ldclient-rb/ldclient"
require "ldclient-rb/store"
require "ldclient-rb/cache_store"
require "ldclient-rb/config"
require "ldclient-rb/newrelic"
require "ldclient-rb/stream"
require "ldclient-rb/polling"
require "ldclient-rb/events"
require "ldclient-rb/feature_store"
require "ldclient-rb/requestor"
File renamed without changes.
55 changes: 26 additions & 29 deletions lib/ldclient-rb/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ class Config
# connections in seconds.
# @option opts [Float] :connect_timeout (2) The connect timeout for network
# connections in seconds.
# @option opts [Object] :store A cache store for the Faraday HTTP caching
# @option opts [Object] :cache_store A cache store for the Faraday HTTP caching
# library. Defaults to the Rails cache in a Rails environment, or a
# thread-safe in-memory store otherwise.
# @option opts [Boolean] :offline (false) Whether the client should be initialized in
# offline mode. In offline mode, default values are returned for all flags and no
# remote network requests are made.
# @option opts [Float] :poll_interval (30) The number of seconds between polls for flag updates
# if streaming is off.
#
# @return [type] [description]
def initialize(opts = {})
Expand All @@ -42,14 +47,14 @@ def initialize(opts = {})
@events_uri = (opts[:events_uri] || Config.default_events_uri).chomp("/")
@capacity = opts[:capacity] || Config.default_capacity
@logger = opts[:logger] || Config.default_logger
@store = opts[:store] || Config.default_store
@cache_store = opts[:cache_store] || Config.default_cache_store
@flush_interval = opts[:flush_interval] || Config.default_flush_interval
@connect_timeout = opts[:connect_timeout] || Config.default_connect_timeout
@read_timeout = opts[:read_timeout] || Config.default_read_timeout
@feature_store = opts[:feature_store] || Config.default_feature_store
@stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream
@log_timings = opts.has_key?(:log_timings) ? opts[:log_timings] : Config.default_log_timings
@debug_stream = opts.has_key?(:debug_stream) ? opts[:debug_stream] : Config.default_debug_stream
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
@poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > 1 ? opts[:poll_interval] : Config.default_poll_interval
end

#
Expand Down Expand Up @@ -79,13 +84,9 @@ def stream?
@stream
end

#
# Whether we should debug streaming mode. If set, the client will fetch features via polling
# and compare the retrieved feature with the value in the feature store
#
# @return [Boolean] True if we should debug streaming mode
def debug_stream?
@debug_stream
# TODO docs
def offline?
@offline
end

#
Expand All @@ -95,6 +96,11 @@ def debug_stream?
# @return [Float] The configured number of seconds between flushes of the event buffer.
attr_reader :flush_interval

#
# The number of seconds to wait before polling for feature flag updates. This option has no
# effect unless streaming is disabled
attr_reader :poll_interval

#
# The configured logger for the LaunchDarkly client. The client library uses the log to
# print warning and error messages.
Expand All @@ -117,7 +123,7 @@ def debug_stream?
# 'read' and 'write' requests.
#
# @return [Object] The configured store for the Faraday HTTP caching library.
attr_reader :store
attr_reader :cache_store

#
# The read timeout for network connections in seconds.
Expand All @@ -132,16 +138,7 @@ def debug_stream?
attr_reader :connect_timeout

#
# Whether timing information should be logged. If it is logged, it will be logged to the DEBUG
# level on the configured logger. This can be very verbose.
#
# @return [Boolean] True if timing information should be logged.
def log_timings?
@log_timings
end

#
# TODO docs
# A store for feature flag configuration rules.
#
attr_reader :feature_store

Expand Down Expand Up @@ -170,7 +167,7 @@ def self.default_events_uri
"https://events.launchdarkly.com"
end

def self.default_store
def self.default_cache_store
defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new
end

Expand All @@ -190,20 +187,20 @@ def self.default_logger
defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout)
end

def self.default_log_timings
false
end

def self.default_stream
true
end

def self.default_feature_store
nil
InMemoryFeatureStore.new
end

def self.default_debug_stream
def self.default_offline
false
end

def self.default_poll_interval
1
end
end
end
Loading