-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: - add rbs to gemspec - add rbs tests to gha - add rbs tests - consider checking using steep / Steepfile
- Loading branch information
Showing
5 changed files
with
132 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# D = Steep::Diagnostic | ||
# | ||
target :lib do | ||
signature "sig" | ||
|
||
# check "lib/unleash/client.rbs" # Directory name | ||
check "lib" # Directory name | ||
# check "Gemfile" # File name | ||
# check "app/models/**/*.rb" # Glob | ||
# ignore "lib/templates/*.rb" | ||
|
||
# library "pathname", "set" # Standard libraries | ||
# library "strong_json" # Gems | ||
|
||
# configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting | ||
# configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting | ||
# configure_code_diagnostics do |hash| # You can setup everything yourself | ||
# hash[D::Ruby::NoMethod] = :information | ||
# end | ||
end | ||
|
||
# target :test do | ||
# # signature "sig", "sig-private" | ||
# # | ||
# check "spec" | ||
# # | ||
# # # library "pathname", "set" # Standard libraries | ||
# end |
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,39 @@ | ||
module Unleash | ||
class Client | ||
attr_accessor fetcher_scheduled_executor: ScheduledExecutor | ||
|
||
attr_accessor metrics_scheduled_executor: ScheduledExecutor | ||
|
||
def initialize: (*untyped opts) -> void | ||
|
||
def is_enabled?: (untyped feature, ?Context? context, ?bool default_value_param) ?{ () -> bool } -> bool | ||
|
||
# enabled? is a more ruby idiomatic method name than is_enabled? | ||
alias enabled? is_enabled? | ||
|
||
# execute a code block (passed as a parameter), if is_enabled? is true. | ||
def if_enabled: (untyped feature, ?Context context, ?bool default_value) { (untyped) -> bool } -> (untyped | nil) | ||
|
||
def get_variant: (untyped feature, ?Context context, ?Variant fallback_variant) -> Variant | ||
|
||
# safe shutdown: also flush metrics to server and toggles to disk | ||
def shutdown: () -> nil | ||
|
||
# quick shutdown: just kill running threads | ||
def shutdown!: () -> nil | ||
|
||
private | ||
|
||
def info: () -> { appName: String, instanceId: String, sdkVersion: String, strategies: Array[String], started: String, interval: Integer } | ||
|
||
def start_toggle_fetcher: () -> nil | ||
|
||
def start_metrics: () -> nil | ||
|
||
def register: () -> nil | ||
|
||
def disabled_variant: () -> Variant | ||
|
||
def first_fetch_is_eager: () -> bool | ||
end | ||
end |
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,21 @@ | ||
module Unleash | ||
class Context | ||
ATTRS: ::Array[:app_name | :environment | :user_id | :session_id | :remote_address | :current_time] | ||
|
||
def initialize: (?::Hash[String, any] params) -> Context | ||
|
||
def to_s: () -> ::String | ||
|
||
def get_by_name: ((String | Symbol) name) -> any | ||
|
||
def include?: ((String | Symbol) name) -> bool | ||
|
||
private | ||
|
||
# Method to fetch values from hash for two types of keys: string in camelCase and symbol in snake_case | ||
def value_for: ((String | Symbol) key, Hash[String, any] params, ?any? default_value) -> any | ||
|
||
# converts CamelCase to snake_case | ||
def underscore: ((String | Symbol) camel_cased_word) -> String | ||
end | ||
end |
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,29 @@ | ||
module Unleash | ||
class ScheduledExecutor | ||
attr_accessor name: String | ||
|
||
attr_accessor interval: Numeric | ||
|
||
attr_accessor max_exceptions: ::Integer | ||
|
||
attr_accessor retry_count: ::Integer | ||
|
||
attr_accessor thread: (Thread | nil) | ||
|
||
attr_accessor immediate_execution: bool | ||
|
||
def initialize: (String name, untyped interval, ?::Integer max_exceptions, ?bool immediate_execution) -> void | ||
|
||
def run: () ?{ () -> nil } -> nil | ||
|
||
def running?: () -> bool | ||
|
||
def exit: () -> nil | ||
|
||
private | ||
|
||
def run_blk: () { () -> nil } -> nil | ||
|
||
def exceeded_max_exceptions?: () -> bool | ||
end | ||
end |
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,15 @@ | ||
module Unleash | ||
class Variant | ||
attr_accessor name: String | ||
|
||
attr_accessor enabled: bool | ||
|
||
attr_accessor payload: String | ||
|
||
def initialize: (?::Hash[String, String] params) -> void | ||
|
||
def to_s: () -> ::String | ||
|
||
def ==: (Variant other) -> bool | ||
end | ||
end |