-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from splitio/development
Release 8.3.0
- Loading branch information
Showing
74 changed files
with
2,628 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'set' | ||
|
||
module SplitIoClient | ||
module Cache | ||
module Filter | ||
class FlagSetsFilter | ||
def initialize(flag_sets = []) | ||
@flag_sets = Set.new(flag_sets) | ||
@should_filter = @flag_sets.any? | ||
end | ||
|
||
def should_filter? | ||
@should_filter | ||
end | ||
|
||
def flag_set_exist?(flag_set) | ||
return true unless @should_filter | ||
|
||
if not flag_set.is_a?(String) or flag_set.empty? | ||
return false | ||
end | ||
|
||
@flag_sets.intersection([flag_set]).any? | ||
end | ||
|
||
def intersect?(flag_sets) | ||
return true unless @should_filter | ||
|
||
if not flag_sets.is_a?(Array) or flag_sets.empty? | ||
return false | ||
end | ||
|
||
@flag_sets.intersection(Set.new(flag_sets)).any? | ||
end | ||
end | ||
end | ||
end | ||
end |
40 changes: 40 additions & 0 deletions
40
lib/splitclient-rb/cache/repositories/flag_sets/memory_repository.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'concurrent' | ||
|
||
module SplitIoClient | ||
module Cache | ||
module Repositories | ||
class MemoryFlagSetsRepository | ||
def initialize(flag_sets = []) | ||
@sets_feature_flag_map = {} | ||
flag_sets.each{ |flag_set| @sets_feature_flag_map[flag_set] = Set[] } | ||
end | ||
|
||
def flag_set_exist?(flag_set) | ||
@sets_feature_flag_map.key?(flag_set) | ||
end | ||
|
||
def get_flag_sets(flag_sets) | ||
to_return = Array.new | ||
flag_sets.each { |flag_set| to_return.concat(@sets_feature_flag_map[flag_set].to_a)} | ||
to_return.uniq | ||
end | ||
|
||
def add_flag_set(flag_set) | ||
@sets_feature_flag_map[flag_set] = Set[] if !flag_set_exist?(flag_set) | ||
end | ||
|
||
def remove_flag_set(flag_set) | ||
@sets_feature_flag_map.delete(flag_set) if flag_set_exist?(flag_set) | ||
end | ||
|
||
def add_feature_flag_to_flag_set(flag_set, feature_flag) | ||
@sets_feature_flag_map[flag_set].add(feature_flag) if flag_set_exist?(flag_set) | ||
end | ||
|
||
def remove_feature_flag_from_flag_set(flag_set, feature_flag) | ||
@sets_feature_flag_map[flag_set].delete(feature_flag) if flag_set_exist?(flag_set) | ||
end | ||
end | ||
end | ||
end | ||
end |
49 changes: 49 additions & 0 deletions
49
lib/splitclient-rb/cache/repositories/flag_sets/redis_repository.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'concurrent' | ||
|
||
module SplitIoClient | ||
module Cache | ||
module Repositories | ||
class RedisFlagSetsRepository < Repository | ||
|
||
def initialize(config) | ||
super(config) | ||
@adapter = SplitIoClient::Cache::Adapters::RedisAdapter.new(@config.redis_url) | ||
end | ||
|
||
def flag_set_exist?(flag_set) | ||
@adapter.exists?(namespace_key(".flagSet.#{flag_set}")) | ||
end | ||
|
||
def get_flag_sets(flag_sets) | ||
result = @adapter.redis.pipelined do |pipeline| | ||
flag_sets.each do |flag_set| | ||
pipeline.smembers(namespace_key(".flagSet.#{flag_set}")) | ||
end | ||
end | ||
to_return = Array.new | ||
result.each do |flag_set| | ||
flag_set.each { |feature_flag_name| to_return.push(feature_flag_name.to_s)} | ||
end | ||
to_return.uniq | ||
end | ||
|
||
def add_flag_set(flag_set) | ||
# not implemented | ||
end | ||
|
||
def remove_flag_set(flag_set) | ||
# not implemented | ||
end | ||
|
||
def add_feature_flag_to_flag_set(flag_set, feature_flag) | ||
# not implemented | ||
end | ||
|
||
def remove_feature_flag_from_flag_set(flag_set, feature_flag) | ||
# not implemented | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.