cosmonats 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +169 -0
- data/README.md +515 -0
- data/bin/cosmo +7 -0
- data/lib/cosmo/cli.rb +201 -0
- data/lib/cosmo/client.rb +54 -0
- data/lib/cosmo/config.rb +101 -0
- data/lib/cosmo/defaults.yml +69 -0
- data/lib/cosmo/engine.rb +46 -0
- data/lib/cosmo/job/data.rb +74 -0
- data/lib/cosmo/job/processor.rb +132 -0
- data/lib/cosmo/job.rb +67 -0
- data/lib/cosmo/logger.rb +66 -0
- data/lib/cosmo/processor.rb +56 -0
- data/lib/cosmo/publisher.rb +38 -0
- data/lib/cosmo/stream/data.rb +21 -0
- data/lib/cosmo/stream/message.rb +31 -0
- data/lib/cosmo/stream/processor.rb +94 -0
- data/lib/cosmo/stream/serializer.rb +19 -0
- data/lib/cosmo/stream.rb +76 -0
- data/lib/cosmo/utils/hash.rb +66 -0
- data/lib/cosmo/utils/json.rb +23 -0
- data/lib/cosmo/utils/signal.rb +24 -0
- data/lib/cosmo/utils/stopwatch.rb +32 -0
- data/lib/cosmo/utils/string.rb +24 -0
- data/lib/cosmo/utils/thread_pool.rb +41 -0
- data/lib/cosmo/version.rb +5 -0
- data/lib/cosmo.rb +39 -0
- data/lib/cosmonats.rb +3 -0
- data/sig/cosmo/cli.rbs +25 -0
- data/sig/cosmo/client.rbs +30 -0
- data/sig/cosmo/config.rbs +48 -0
- data/sig/cosmo/engine.rbs +21 -0
- data/sig/cosmo/job/data.rbs +35 -0
- data/sig/cosmo/job/processor.rbs +23 -0
- data/sig/cosmo/job.rbs +35 -0
- data/sig/cosmo/logger.rbs +39 -0
- data/sig/cosmo/message.rbs +38 -0
- data/sig/cosmo/processor.rbs +29 -0
- data/sig/cosmo/publisher.rbs +21 -0
- data/sig/cosmo/stream/data.rbs +7 -0
- data/sig/cosmo/stream/processor.rbs +26 -0
- data/sig/cosmo/stream/serializer.rbs +13 -0
- data/sig/cosmo/stream.rbs +38 -0
- data/sig/cosmo/utils/hash.rbs +25 -0
- data/sig/cosmo/utils/json.rbs +13 -0
- data/sig/cosmo/utils/signal.rbs +15 -0
- data/sig/cosmo/utils/stopwatch.rbs +19 -0
- data/sig/cosmo/utils/string.rbs +13 -0
- data/sig/cosmo/utils/thread_pool.rbs +18 -0
- data/sig/cosmo.rbs +20 -0
- metadata +125 -0
data/lib/cosmo.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cosmo/utils/hash"
|
|
4
|
+
require "cosmo/utils/json"
|
|
5
|
+
require "cosmo/utils/string"
|
|
6
|
+
require "cosmo/utils/signal"
|
|
7
|
+
require "cosmo/utils/stopwatch"
|
|
8
|
+
require "cosmo/utils/thread_pool"
|
|
9
|
+
|
|
10
|
+
require "cosmo/client"
|
|
11
|
+
require "cosmo/publisher"
|
|
12
|
+
require "cosmo/processor"
|
|
13
|
+
require "cosmo/version"
|
|
14
|
+
require "cosmo/config"
|
|
15
|
+
require "cosmo/logger"
|
|
16
|
+
require "cosmo/job"
|
|
17
|
+
require "cosmo/stream"
|
|
18
|
+
require "cosmo/cli"
|
|
19
|
+
require "cosmo/engine"
|
|
20
|
+
|
|
21
|
+
module Cosmo
|
|
22
|
+
class Error < StandardError; end
|
|
23
|
+
|
|
24
|
+
class ArgumentError < Error; end
|
|
25
|
+
|
|
26
|
+
class NotImplementedError < Error; end
|
|
27
|
+
|
|
28
|
+
class ConfigNotFoundError < Error
|
|
29
|
+
def initialize(config_file)
|
|
30
|
+
super("No such file #{config_file}")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class StreamNotFoundError < Error
|
|
35
|
+
def initialize(stream_name)
|
|
36
|
+
super("Missing stream `#{stream_name}`")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/cosmonats.rb
ADDED
data/sig/cosmo/cli.rbs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class CLI
|
|
3
|
+
self.@instance: CLI
|
|
4
|
+
|
|
5
|
+
def self.run: () -> void
|
|
6
|
+
|
|
7
|
+
def self.instance: -> CLI
|
|
8
|
+
|
|
9
|
+
def self.banner: () -> ::String
|
|
10
|
+
|
|
11
|
+
def run: () -> void
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def parse: () -> [Hash[Symbol, untyped], ::String?, Hash[Symbol, untyped]]
|
|
16
|
+
|
|
17
|
+
def load_config: (::String? path) -> void
|
|
18
|
+
|
|
19
|
+
def require_files: (::String? path) -> void
|
|
20
|
+
|
|
21
|
+
def flags_parser: (Hash[Symbol, untyped] flags) -> untyped
|
|
22
|
+
|
|
23
|
+
def options_parser: (::String? command, Hash[Symbol, untyped] options) -> untyped
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class Client
|
|
3
|
+
self.@instance: Client
|
|
4
|
+
@nc: untyped
|
|
5
|
+
@js: untyped
|
|
6
|
+
|
|
7
|
+
def self.instance: () -> Client
|
|
8
|
+
|
|
9
|
+
attr_reader nc: untyped
|
|
10
|
+
attr_reader js: untyped
|
|
11
|
+
|
|
12
|
+
def initialize: (?nats_url: ::String) -> void
|
|
13
|
+
|
|
14
|
+
def publish: (::String subject, ::String payload, **untyped params) -> untyped
|
|
15
|
+
|
|
16
|
+
def subscribe: (::String | Array[::String] subject, ::String consumer_name, Hash[Symbol, untyped] config) -> untyped
|
|
17
|
+
|
|
18
|
+
def stream_info: (::String | Symbol name) -> untyped
|
|
19
|
+
|
|
20
|
+
def create_stream: (::String | Symbol name, Hash[Symbol, untyped] config) -> untyped
|
|
21
|
+
|
|
22
|
+
def delete_stream: (::String | Symbol name, Hash[Symbol, untyped] params) -> untyped
|
|
23
|
+
|
|
24
|
+
def list_streams: -> Array[::String]
|
|
25
|
+
|
|
26
|
+
def get_message: (::String | Symbol name, Integer seq) -> NATS::JetStream::API::RawStreamMsg
|
|
27
|
+
|
|
28
|
+
def close: -> void
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class Config
|
|
3
|
+
NANO: Integer
|
|
4
|
+
DEFAULT_PATH: ::String
|
|
5
|
+
|
|
6
|
+
self.@instance: Config
|
|
7
|
+
self.@system: Hash[Symbol, untyped]
|
|
8
|
+
@config: Hash[Symbol, untyped]?
|
|
9
|
+
@system: Hash[Symbol, untyped]
|
|
10
|
+
@defaults: Hash[Symbol, untyped]
|
|
11
|
+
|
|
12
|
+
def self.instance: () -> Config
|
|
13
|
+
|
|
14
|
+
def self.system: () -> Hash[Symbol, untyped]
|
|
15
|
+
|
|
16
|
+
def self.parse_file: (::String path) -> Hash[Symbol, untyped]
|
|
17
|
+
|
|
18
|
+
def self.normalize!: (Hash[Symbol, untyped] config) -> void
|
|
19
|
+
|
|
20
|
+
def self.deliver_policy: (Symbol | ::String | Time start_position) -> Hash[Symbol, ::String]
|
|
21
|
+
|
|
22
|
+
def self.[]: (Symbol key) -> untyped
|
|
23
|
+
|
|
24
|
+
def self.fetch: (Symbol key, ?untyped default) -> untyped
|
|
25
|
+
|
|
26
|
+
def self.dig: (*Symbol keys) -> untyped
|
|
27
|
+
|
|
28
|
+
def self.to_h: () -> Hash[Symbol, untyped]
|
|
29
|
+
|
|
30
|
+
def self.set: (*untyped) -> untyped
|
|
31
|
+
|
|
32
|
+
def self.load: (?::String? path) -> void
|
|
33
|
+
|
|
34
|
+
def initialize: () -> void
|
|
35
|
+
|
|
36
|
+
def []: (Symbol key) -> untyped
|
|
37
|
+
|
|
38
|
+
def fetch: (Symbol key, ?untyped default) -> untyped
|
|
39
|
+
|
|
40
|
+
def dig: (*Symbol keys) -> untyped
|
|
41
|
+
|
|
42
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
43
|
+
|
|
44
|
+
def set: (*untyped) -> untyped
|
|
45
|
+
|
|
46
|
+
def load: (?::String? path) -> void
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class Engine
|
|
3
|
+
PROCESSORS: Hash[Symbol, Class]
|
|
4
|
+
|
|
5
|
+
self.@instance: Engine
|
|
6
|
+
@concurrency: Integer
|
|
7
|
+
@pool: Utils::ThreadPool
|
|
8
|
+
@running: untyped
|
|
9
|
+
@processors: Array[Processor]
|
|
10
|
+
|
|
11
|
+
def self.run: (*untyped) -> void
|
|
12
|
+
|
|
13
|
+
def self.instance: () -> Engine
|
|
14
|
+
|
|
15
|
+
def initialize: () -> void
|
|
16
|
+
|
|
17
|
+
def run: (::String? type) -> void
|
|
18
|
+
|
|
19
|
+
def shutdown: () -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Job
|
|
3
|
+
class Data
|
|
4
|
+
DEFAULTS: { stream: Symbol, retry: Integer | bool, dead: bool }
|
|
5
|
+
|
|
6
|
+
@class_name: ::String
|
|
7
|
+
@args: Array[untyped]
|
|
8
|
+
@options: Hash[Symbol, untyped]
|
|
9
|
+
@at: Integer?
|
|
10
|
+
@subject: ::String?
|
|
11
|
+
|
|
12
|
+
attr_reader jid: ::String
|
|
13
|
+
|
|
14
|
+
def initialize: (::String class_name, Array[untyped] args, ?Hash[Symbol, untyped]? options) -> void
|
|
15
|
+
|
|
16
|
+
def stream: (?target: bool) -> Symbol
|
|
17
|
+
|
|
18
|
+
def subject: (?target: bool) -> Array[::String]
|
|
19
|
+
|
|
20
|
+
def as_json: () -> { jid: ::String, class: ::String, args: Array[untyped], retry: Integer, dead: bool }
|
|
21
|
+
|
|
22
|
+
def to_json: (*untyped _args) -> ::String?
|
|
23
|
+
|
|
24
|
+
def to_args: () -> [::String, ::String, Hash[Symbol, untyped]]
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def validate!: () -> void
|
|
29
|
+
|
|
30
|
+
def retries: () -> (Integer | bool)
|
|
31
|
+
|
|
32
|
+
def dead: () -> bool
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Job
|
|
3
|
+
class Processor < ::Cosmo::Processor
|
|
4
|
+
@weights: Array[Symbol]
|
|
5
|
+
|
|
6
|
+
def initialize: (Utils::ThreadPool pool, untyped running) -> void
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def run_loop: () -> void
|
|
11
|
+
|
|
12
|
+
def setup: () -> void
|
|
13
|
+
|
|
14
|
+
def work_loop: () -> void
|
|
15
|
+
|
|
16
|
+
def schedule_loop: () -> void
|
|
17
|
+
|
|
18
|
+
def process: (Array[untyped] messages) -> void
|
|
19
|
+
|
|
20
|
+
def handle_failure: (untyped message, Hash[Symbol, untyped] data) -> void
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/sig/cosmo/job.rbs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Job
|
|
3
|
+
def self.included: (Class base) -> void
|
|
4
|
+
|
|
5
|
+
module ClassMethods
|
|
6
|
+
@default_options: Hash[Symbol, untyped]
|
|
7
|
+
|
|
8
|
+
def options: (?stream: Symbol?, ?retry: Integer?, ?dead: bool?) -> Hash[Symbol, untyped]
|
|
9
|
+
|
|
10
|
+
def perform: (*untyped args, ?async: bool, **untyped options) -> (::String | nil)
|
|
11
|
+
|
|
12
|
+
def perform_async: (*untyped args) -> ::String
|
|
13
|
+
|
|
14
|
+
def perform_at: (Integer | Time timestamp, *untyped args) -> ::String
|
|
15
|
+
|
|
16
|
+
def perform_in: (Integer | Float interval, *untyped args) -> ::String
|
|
17
|
+
|
|
18
|
+
def perform_sync: (*untyped args) -> void
|
|
19
|
+
|
|
20
|
+
def default_options: () -> Hash[Symbol, untyped]
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def client: () -> Client
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
attr_reader jid: ::String
|
|
28
|
+
|
|
29
|
+
def jid=: (::String) -> ::String
|
|
30
|
+
|
|
31
|
+
def perform: (*untyped) -> untyped
|
|
32
|
+
|
|
33
|
+
def logger: () -> untyped
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Logger
|
|
3
|
+
module Context
|
|
4
|
+
KEY: Symbol
|
|
5
|
+
|
|
6
|
+
def self.with: (**untyped options) ?{ () -> void } -> (nil | Hash[Symbol, untyped])
|
|
7
|
+
|
|
8
|
+
def self.without: (*Symbol keys) -> nil
|
|
9
|
+
|
|
10
|
+
def self.current: () -> Hash[Symbol, untyped]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class BaseFormatter
|
|
14
|
+
def tid: () -> ::String
|
|
15
|
+
|
|
16
|
+
def pid: () -> Integer
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class SimpleFormatter < BaseFormatter
|
|
20
|
+
def call: (::String severity, Time time, untyped _, ::String msg) -> ::String
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.info: (::String) -> void
|
|
24
|
+
|
|
25
|
+
def self.error: (::String | Exception) -> void
|
|
26
|
+
|
|
27
|
+
def self.debug: (::String | Exception) -> void
|
|
28
|
+
|
|
29
|
+
def self.warn: (::String) -> void
|
|
30
|
+
|
|
31
|
+
def self.fatal: (::String) -> void
|
|
32
|
+
|
|
33
|
+
def self.with: (**untyped) ?{ () -> void } -> void
|
|
34
|
+
|
|
35
|
+
def self.without: (*Symbol) -> nil
|
|
36
|
+
|
|
37
|
+
def self.instance: () -> untyped
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Stream
|
|
3
|
+
class Message
|
|
4
|
+
@msg: untyped
|
|
5
|
+
@serializer: Module
|
|
6
|
+
|
|
7
|
+
def initialize: (untyped msg, ?serializer: Module?) -> void
|
|
8
|
+
|
|
9
|
+
def subject: () -> ::String
|
|
10
|
+
|
|
11
|
+
def reply: () -> ::String?
|
|
12
|
+
|
|
13
|
+
def header: () -> Hash[::String, untyped]
|
|
14
|
+
|
|
15
|
+
def ack: () -> void
|
|
16
|
+
|
|
17
|
+
def nack: (?delay: Integer?) -> void
|
|
18
|
+
|
|
19
|
+
def term: () -> void
|
|
20
|
+
|
|
21
|
+
def data: () -> untyped
|
|
22
|
+
|
|
23
|
+
def metadata: () -> untyped
|
|
24
|
+
|
|
25
|
+
def stream_sequence: () -> Integer
|
|
26
|
+
|
|
27
|
+
def consumer_sequence: () -> Integer
|
|
28
|
+
|
|
29
|
+
def timestamp: () -> Time
|
|
30
|
+
|
|
31
|
+
def num_delivered: () -> Integer
|
|
32
|
+
|
|
33
|
+
def num_pending: () -> Integer
|
|
34
|
+
|
|
35
|
+
def in_progress: () -> void
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class Processor
|
|
3
|
+
@pool: Utils::ThreadPool
|
|
4
|
+
@running: untyped
|
|
5
|
+
@consumers: Hash[Symbol, untyped]
|
|
6
|
+
|
|
7
|
+
def self.run: (*untyped) -> Processor
|
|
8
|
+
|
|
9
|
+
def initialize: (Utils::ThreadPool pool, untyped running) -> void
|
|
10
|
+
|
|
11
|
+
def run: () -> void
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def run_loop: () -> void
|
|
16
|
+
|
|
17
|
+
def setup: () -> void
|
|
18
|
+
|
|
19
|
+
def process: (*untyped) -> void
|
|
20
|
+
|
|
21
|
+
def running?: () -> bool
|
|
22
|
+
|
|
23
|
+
def fetch_messages: (Symbol stream_name, batch_size: Integer, timeout: Float) ?{ (Array[untyped]) -> void } -> void
|
|
24
|
+
|
|
25
|
+
def client: () -> Client
|
|
26
|
+
|
|
27
|
+
def stopwatch: () -> Utils::Stopwatch
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
class Publisher
|
|
3
|
+
@client: Client
|
|
4
|
+
|
|
5
|
+
def self.instance: () -> Publisher
|
|
6
|
+
|
|
7
|
+
def self.publish: (::String subject, untyped data, ?serializer: Module?, **untyped options) -> bool
|
|
8
|
+
|
|
9
|
+
def self.publish_job: (Job::Data data) -> ::String
|
|
10
|
+
|
|
11
|
+
def self.publish_batch: (::String subject, Array[untyped] batch, **untyped options) -> void
|
|
12
|
+
|
|
13
|
+
def initialize: () -> void
|
|
14
|
+
|
|
15
|
+
def publish: (::String subject, untyped data, ?serializer: Module?, **untyped options) -> untyped
|
|
16
|
+
|
|
17
|
+
def publish_job: (Job::Data data) -> ::String
|
|
18
|
+
|
|
19
|
+
def publish_batch: (::String subject, Array[untyped] batch, **untyped options) -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Stream
|
|
3
|
+
class Processor < ::Cosmo::Processor
|
|
4
|
+
@configs: Hash[Symbol, Hash[Symbol, untyped]]
|
|
5
|
+
@processors: Hash[Symbol, untyped]
|
|
6
|
+
|
|
7
|
+
def initialize: (Utils::ThreadPool pool, untyped running) -> void
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def run_loop: () -> void
|
|
12
|
+
|
|
13
|
+
def setup: () -> void
|
|
14
|
+
|
|
15
|
+
def work_loop: () -> void
|
|
16
|
+
|
|
17
|
+
def process: (Symbol stream_name, Array[untyped] messages) -> void
|
|
18
|
+
|
|
19
|
+
def setup_configs: () -> void
|
|
20
|
+
|
|
21
|
+
def setup_processors: () -> void
|
|
22
|
+
|
|
23
|
+
def setup_consumers: () -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Stream
|
|
3
|
+
module Serializer
|
|
4
|
+
def self.serialize: (untyped data) -> ::String?
|
|
5
|
+
|
|
6
|
+
def self.deserialize: (::String payload) -> untyped
|
|
7
|
+
|
|
8
|
+
def deserialize: (::String payload) -> untyped
|
|
9
|
+
|
|
10
|
+
def serialize: (untyped data) -> ::String?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Stream
|
|
3
|
+
def self.included: (Class base) -> void
|
|
4
|
+
|
|
5
|
+
module ClassMethods
|
|
6
|
+
@default_options: Hash[Symbol, untyped]
|
|
7
|
+
|
|
8
|
+
def options: (
|
|
9
|
+
?stream: Symbol?,
|
|
10
|
+
?consumer_name: ::String?,
|
|
11
|
+
?batch_size: Integer?,
|
|
12
|
+
?start_position: (Symbol | ::String | Time)?,
|
|
13
|
+
?consumer: Hash[Symbol, untyped]?,
|
|
14
|
+
?publisher: Hash[Symbol, untyped]?
|
|
15
|
+
) -> Hash[Symbol, untyped]
|
|
16
|
+
|
|
17
|
+
def publish: (untyped data, ?subject: ::String?, **untyped options) -> bool
|
|
18
|
+
|
|
19
|
+
def default_options: () -> Hash[Symbol, untyped]
|
|
20
|
+
|
|
21
|
+
def register: () -> void
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def process: (Array[Message] messages) -> void
|
|
25
|
+
|
|
26
|
+
def process_batch: (Array[Message] messages) -> void
|
|
27
|
+
|
|
28
|
+
def process_many: (Array[Message] messages) -> void
|
|
29
|
+
|
|
30
|
+
def process_one: () -> void
|
|
31
|
+
|
|
32
|
+
def logger: () -> untyped
|
|
33
|
+
|
|
34
|
+
def message: () -> Message?
|
|
35
|
+
|
|
36
|
+
def publish: (untyped data, ::String subject, **untyped options) -> bool
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Utils
|
|
3
|
+
module Hash
|
|
4
|
+
def self.symbolize_keys!: (untyped obj) -> (::Hash[Symbol, untyped] | Array[untyped] | untyped)
|
|
5
|
+
|
|
6
|
+
def self.dup: [T] (T hash) -> T
|
|
7
|
+
|
|
8
|
+
def self.keys?: (::Hash[untyped, untyped] hash, *untyped keys) -> bool
|
|
9
|
+
|
|
10
|
+
def self.set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
|
|
11
|
+
|
|
12
|
+
def self.merge: (::Hash[untyped, untyped] hash1, ::Hash[untyped, untyped]? hash2) -> ::Hash[untyped, untyped]
|
|
13
|
+
|
|
14
|
+
def symbolize_keys!: (untyped obj) -> (::Hash[Symbol, untyped] | Array[untyped] | untyped)
|
|
15
|
+
|
|
16
|
+
def dup: [T] (T hash) -> T
|
|
17
|
+
|
|
18
|
+
def keys?: (::Hash[untyped, untyped] hash, *untyped keys) -> bool
|
|
19
|
+
|
|
20
|
+
def set: (::Hash[untyped, untyped] hash, *untyped keys, value: untyped) -> untyped
|
|
21
|
+
|
|
22
|
+
def merge: (::Hash[untyped, untyped] hash1, ::Hash[untyped, untyped]? hash2) -> ::Hash[untyped, untyped]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Utils
|
|
3
|
+
module Json
|
|
4
|
+
def self.parse: (::String value, ?default: untyped?, ?symbolize_names: bool, **untyped options) -> untyped
|
|
5
|
+
|
|
6
|
+
def self.dump: (untyped value, ?default: untyped?) -> ::String?
|
|
7
|
+
|
|
8
|
+
def parse: (::String value, ?default: untyped?, ?symbolize_names: bool, **untyped options) -> untyped
|
|
9
|
+
|
|
10
|
+
def dump: (untyped value, ?default: untyped?) -> ::String?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Utils
|
|
3
|
+
class Stopwatch
|
|
4
|
+
@started_at: Float
|
|
5
|
+
|
|
6
|
+
def initialize: () -> void
|
|
7
|
+
|
|
8
|
+
def elapsed_millis: () -> Float
|
|
9
|
+
|
|
10
|
+
def elapsed_seconds: () -> Float
|
|
11
|
+
|
|
12
|
+
def reset: () -> void
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def clock_time: () -> Float
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Utils
|
|
3
|
+
module String
|
|
4
|
+
def self.underscore: (::String | Symbol value) -> ::String
|
|
5
|
+
|
|
6
|
+
def self.safe_constantize: (::String value) -> Class?
|
|
7
|
+
|
|
8
|
+
def underscore: (::String | Symbol value) -> ::String
|
|
9
|
+
|
|
10
|
+
def safe_constantize: (::String value) -> Class?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
module Utils
|
|
3
|
+
class ThreadPool
|
|
4
|
+
@mutex: Thread::Mutex
|
|
5
|
+
@available: Integer
|
|
6
|
+
@cond: Thread::ConditionVariable
|
|
7
|
+
@pool: untyped
|
|
8
|
+
|
|
9
|
+
def initialize: (Integer concurrency) -> void
|
|
10
|
+
|
|
11
|
+
def post: () { () -> void } -> void
|
|
12
|
+
|
|
13
|
+
def shutdown: () -> void
|
|
14
|
+
|
|
15
|
+
def wait_for_termination: (Integer? timeout) -> bool
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/sig/cosmo.rbs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Cosmo
|
|
2
|
+
VERSION: ::String
|
|
3
|
+
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class ArgumentError < Error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class NotImplementedError < Error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class ConfigNotFoundError < Error
|
|
14
|
+
def initialize: (::String config_file) -> void
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class StreamNotFoundError < Error
|
|
18
|
+
def initialize: (::String stream_name) -> void
|
|
19
|
+
end
|
|
20
|
+
end
|