nats-pure 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -0
  3. data/README.md +251 -0
  4. data/lib/nats/io/client.rb +215 -144
  5. data/lib/nats/io/errors.rb +6 -0
  6. data/lib/nats/io/jetstream/msg/ack_methods.rb +8 -4
  7. data/lib/nats/io/msg.rb +3 -1
  8. data/lib/nats/io/rails.rb +29 -0
  9. data/lib/nats/io/subscription.rb +70 -5
  10. data/lib/nats/io/version.rb +1 -1
  11. data/lib/nats/io/websocket.rb +75 -0
  12. data/sig/nats/io/client.rbs +304 -0
  13. data/sig/nats/io/errors.rbs +54 -0
  14. data/sig/nats/io/jetstream/api.rbs +35 -0
  15. data/sig/nats/io/jetstream/errors.rbs +54 -0
  16. data/sig/nats/io/jetstream/js/config.rbs +11 -0
  17. data/sig/nats/io/jetstream/js/header.rbs +17 -0
  18. data/sig/nats/io/jetstream/js/status.rbs +13 -0
  19. data/sig/nats/io/jetstream/js/sub.rbs +14 -0
  20. data/sig/nats/io/jetstream/js.rbs +27 -0
  21. data/sig/nats/io/jetstream/manager.rbs +33 -0
  22. data/sig/nats/io/jetstream/msg/ack.rbs +35 -0
  23. data/sig/nats/io/jetstream/msg/ack_methods.rbs +25 -0
  24. data/sig/nats/io/jetstream/msg/metadata.rbs +15 -0
  25. data/sig/nats/io/jetstream/msg.rbs +6 -0
  26. data/sig/nats/io/jetstream/pull_subscription.rbs +14 -0
  27. data/sig/nats/io/jetstream/push_subscription.rbs +7 -0
  28. data/sig/nats/io/jetstream.rbs +15 -0
  29. data/sig/nats/io/kv/api.rbs +8 -0
  30. data/sig/nats/io/kv/bucket_status.rbs +17 -0
  31. data/sig/nats/io/kv/errors.rbs +30 -0
  32. data/sig/nats/io/kv/manager.rbs +11 -0
  33. data/sig/nats/io/kv.rbs +39 -0
  34. data/sig/nats/io/msg.rbs +14 -0
  35. data/sig/nats/io/parser.rbs +32 -0
  36. data/sig/nats/io/subscription.rbs +33 -0
  37. data/sig/nats/io/version.rbs +9 -0
  38. data/sig/nats/nuid.rbs +32 -0
  39. metadata +49 -4
@@ -0,0 +1,27 @@
1
+ module NATS
2
+ class JetStream
3
+ module JS
4
+ DefaultAPIPrefix: '$JS.API'
5
+
6
+ # class << self
7
+ def self.next_req_to_json: (Hash[Symbol, untyped]) -> String
8
+
9
+ def self.is_status_msg: (NATS::Msg) -> bool
10
+
11
+ def self.check_503_error: (NATS::Msg) -> void
12
+
13
+ def self.from_msg: (NATS::Msg) -> NATS::JetStream::API::Error
14
+
15
+ def self.from_error: (Hash[Symbol, untyped]) -> (
16
+ NATS::JetStream::Error::ServiceUnavailable |
17
+ NATS::JetStream::Error::ServerError |
18
+ NATS::JetStream::Error::StreamNotFound |
19
+ NATS::JetStream::Error::ConsumerNotFound |
20
+ NATS::JetStream::Error::NotFound |
21
+ NATS::JetStream::Error::BadRequest |
22
+ NATS::JetStream::API::Error
23
+ )
24
+ # end class << self
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module NATS
2
+ class JetStream
3
+ module Manager
4
+ def add_stream: (JetStream::API::StreamConfig, ?Hash[Symbol, untyped]) -> JetStream::API::StreamCreateResponse
5
+
6
+ def stream_info: (String, ?Hash[Symbol, untyped]) -> JetStream::API::StreamInfo
7
+
8
+ def update_stream: (JetStream::API::StreamConfig, ?Hash[Symbol, untyped]) -> JetStream::API::StreamCreateResponse
9
+
10
+ def delete_stream: (String, ?Hash[Symbol, untyped]) -> bool
11
+
12
+ def add_consumer: (String, JetStream::API::ConsumerConfig, ?Hash[Symbol, untyped]) -> JetStream::API::ConsumerInfo
13
+
14
+ def consumer_info: (String, String, ?Hash[Symbol, untyped]) -> JetStream::API::ConsumerInfo
15
+
16
+ def delete_consumer: (String, String, ?Hash[Symbol, untyped]) -> bool
17
+
18
+ def find_stream_name_by_subject: (String, ?Hash[Symbol, untyped]) -> String
19
+
20
+ def get_msg: (String, ?Hash[Symbol, untyped]) -> JetStream::API::RawStreamMsg
21
+
22
+ def get_last_msg: (String, String, ?Hash[Symbol, untyped]) -> JetStream::API::RawStreamMsg
23
+
24
+ def account_info: () -> Hash[Symbol, untyped]
25
+
26
+ private
27
+
28
+ def api_request: (String, String, ?Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
29
+
30
+ def _lift_msg_to_raw_msg: (NATS::Msg) -> JetStream::API::RawStreamMsg
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ module NATS
2
+ class JetStream
3
+ module Msg
4
+ module Ack
5
+ Ack: '+ACK'
6
+ Nak: '-NAK'
7
+ Progress: '+WPI'
8
+ Term: '+TERM'
9
+
10
+ Empty: ''
11
+ DotSep: '.'
12
+ NoDomainName: '_'
13
+
14
+ Prefix0: '$JS'
15
+ Prefix1: 'ACK'
16
+ Domain: 2
17
+ AccHash: 3
18
+ Stream: 4
19
+ Consumer: 5
20
+ NumDelivered: 6
21
+ StreamSeq: 7
22
+ ConsumerSeq: 8
23
+ Timestamp: 9
24
+ NumPending: 10
25
+
26
+ V1TokenCounts: 9
27
+
28
+ V2TokenCounts: 12
29
+
30
+ class SequencePair < Struct[untyped]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ module NATS
2
+ class JetStream
3
+ module Msg
4
+ module AckMethods
5
+ def ack: (**Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
6
+
7
+ def ack_sync: (**Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
8
+
9
+ def nak: (**Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
10
+
11
+ def term: (**Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
12
+
13
+ def in_progress: (**Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
14
+
15
+ def metadata: () -> NATS::JetStream::Msg::Metadata
16
+
17
+ private
18
+
19
+ def ensure_is_acked_once!: () -> void
20
+
21
+ def parse_metadata: (String) -> NATS::JetStream::Msg::Metadata
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module NATS
2
+ class JetStream
3
+ module Msg
4
+ module Metadata
5
+ attr_reader sequence: Ack::SequencePair
6
+ attr_reader num_delivered: Integer
7
+ attr_reader num_pending: Integer
8
+ attr_reader timestamp: Time
9
+ attr_reader stream: String
10
+ attr_reader consumer: String
11
+ attr_reader domain: String
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module NATS
2
+ class JetStream
3
+ module Msg
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ module NATS
2
+ class JetStream
3
+ module PullSubscription
4
+ class PubAck < Struct[String | Numeric | bool]
5
+ end
6
+
7
+ def next_msg: (untyped) -> void
8
+
9
+ def fetch: (Integer, Hash[Symbol, untyped]) -> Array[NATS::Msg]
10
+
11
+ def consumer_info: (Hash[Symbol, untyped]) -> NATS::JetStream::ConsumerInfo
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module NATS
2
+ class JetStream
3
+ module PushSubscription
4
+ def consumer_info: (Hash[Symbol, untyped]) -> NATS::JetStream::ConsumerInfo
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module NATS
2
+ class JetStream
3
+ extend Manager
4
+ extend KeyValue::Manager
5
+
6
+ class PubAck < Struct[String | Numeric | bool]
7
+ end
8
+
9
+ def publish: (String, String, Hash[Symbol, untyped]) -> NATS::JetStream::PubAck
10
+
11
+ def subscribe: (String, Hash[Symbol, untyped]) { (?(NATS::Msg | String), ?String, ?String, ?Hash[Symbol, untyped]) -> void } -> NATS::JetStream::PushSubscription
12
+
13
+ def pull_subscribe: (String, String, Hash[Symbol, untyped]) -> NATS::JetStream::PullSubscription
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module NATS
2
+ class KeyValue
3
+ module API
4
+ class KeyValueConfig < Struct[untyped]
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module NATS
2
+ class KeyValue
3
+ module BucketStatus
4
+ attr_reader bucket: String
5
+
6
+ @nfo: JetStream::API::StreamInfo
7
+
8
+ def initialize: (JetStream::API::StreamInfo, String) -> void
9
+
10
+ def values: () -> Integer
11
+
12
+ def history: () -> Integer
13
+
14
+ def ttl: () -> Float
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module NATS
2
+ class KeyValue
3
+ class Error < NATS::Error
4
+ end
5
+
6
+ class KeyNotFoundError < NATS::KeyValue::Error
7
+ attr_reader entry: NATS::KeyValue::Entry
8
+ attr_reader op: String
9
+
10
+ @message: String
11
+
12
+ def initialize: (Hash[Symbol, untyped]) -> void
13
+ end
14
+
15
+ class KeyDeletedError < NATS::KeyValue::KeyNotFoundError
16
+ end
17
+
18
+ class BucketNotFoundError < NATS::KeyValue::Error
19
+ end
20
+
21
+ class BadBucketError < NATS::KeyValue::Error
22
+ end
23
+
24
+ class KeyWrongLastSequenceError < NATS::KeyValue::Error
25
+ @msg: String
26
+
27
+ def initialize: (String) -> void
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ module NATS
2
+ class KeyValue
3
+ module Manager
4
+ def key_value: (String) -> NATS::KeyValue
5
+
6
+ def create_key_value: (NATS::KeyValue::API::KeyValueConfig) -> NATS::KeyValue
7
+
8
+ def delete_key_value: (String) -> bool
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ module NATS
2
+ class KeyValue
3
+ KV_OP: 'KV-Operation'
4
+ KV_DEL: 'DEL'
5
+ KV_PURGE: 'PURGE'
6
+ MSG_ROLLUP_SUBJECT: 'sub'
7
+ MSG_ROLLUP_ALL: 'all'
8
+ ROLLUP: 'Nats-Rollup'
9
+
10
+ @name: String
11
+ @stream: String
12
+ @pre: String
13
+ @js: NATS::JetStream
14
+ @direct: bool
15
+
16
+ def initialize: (Hash[Symbol, untyped]) -> void
17
+
18
+ def get: (String, ?Hash[Symbol, untyped]) -> NATS::KeyValue::Entry
19
+
20
+ private def _get: (String, ?Hash[Symbol, untyped]) -> NATS::KeyValue::Entry
21
+
22
+ def put: (String, untyped) -> Integer
23
+
24
+ def create: (String, untyped) -> Integer
25
+
26
+ EXPECTED_LAST_SUBJECT_SEQUENCE: 'Nats-Expected-Last-Subject-Sequence'
27
+
28
+ def update: (String, untyped, ?Hash[Symbol, untyped]) -> Integer
29
+
30
+ def delete: (String, ?Hash[Symbol, untyped]) -> Integer
31
+
32
+ def purge: (String) -> NATS::JetStream::PubAck
33
+
34
+ def status: () -> NATS::KeyValue::BucketStatus
35
+
36
+ class Entry < Struct[untyped]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ module NATS
2
+ class Msg
3
+ attr_reader subject: String
4
+ attr_reader reply: String?
5
+ attr_reader data: String
6
+ attr_reader header: String
7
+
8
+ include NATS::JetStream::Msg::AckMethods
9
+
10
+ def respond: (?String) -> void
11
+
12
+ def respond_msg: (NATS::Msg) -> void
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ module NATS
2
+ module Protocol
3
+ MSG: Regexp
4
+ HMSG: Regexp
5
+ OK: Regexp
6
+ ERR: Regexp
7
+ PING: Regexp
8
+ PONG: Regexp
9
+ INFO: Regexp
10
+ UNKNOWN: Regexp
11
+
12
+ AWAITING_CONTROL_LINE: 1
13
+ AWAITING_MSG_PAYLOAD: 2
14
+
15
+ CR_LF: '\r\n'
16
+ CR_LF_SIZE: Integer
17
+
18
+ PING_REQUEST: String
19
+ PONG_RESPONSE: String
20
+
21
+ SUB_OP: 'SUB'
22
+ EMPTY_MSG: ''
23
+
24
+ class Parser
25
+ def initialize: (NATS::Client) -> void
26
+
27
+ def reset!: () -> void
28
+
29
+ def parse: (String) -> void
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ module NATS
2
+ class Subscription
3
+ include MonitorMixin
4
+
5
+ attr_accessor subject: String
6
+ attr_accessor queue: untyped
7
+ attr_accessor future: MonitorMixin::ConditionVariable?
8
+ attr_accessor callback: Proc?
9
+ attr_accessor response: NATS::Msg?
10
+ attr_accessor received: Integer
11
+ attr_accessor max: Integer?
12
+ attr_accessor pending: untyped
13
+ attr_accessor sid: Integer?
14
+
15
+ attr_accessor pending_queue: Thread::SizedQueue?
16
+ attr_accessor pending_size: Integer
17
+ attr_accessor wait_for_msgs_cond: MonitorMixin::ConditionVariable?
18
+
19
+ attr_accessor pending_msgs_limit: Integer?
20
+ attr_accessor pending_bytes_limit: Integer?
21
+
22
+ attr_accessor nc: NATS::Client?
23
+ attr_accessor jsi: NATS::JetStream::JS::Sub
24
+ attr_accessor closed: bool?
25
+
26
+ attr_accessor processing_concurrency: Integer
27
+ attr_reader concurrency_semaphore: Concurrent::Semaphore
28
+
29
+ def unsubscribe: (?Integer?) -> void
30
+
31
+ def next_msg: (Hash[Symbol, untyped]?) -> NATS::Msg
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ module NATS
2
+ module IO
3
+ VERSION: String
4
+
5
+ LANG: String
6
+
7
+ Protocol: Integer
8
+ end
9
+ end
data/sig/nats/nuid.rbs ADDED
@@ -0,0 +1,32 @@
1
+ module NATS
2
+ class NUID
3
+ DIGITS: Array[String]
4
+ BASE: Integer
5
+ PREFIX_LENGTH: Integer
6
+ SEQ_LENGTH: Integer
7
+ TOTAL_LENGTH: Integer
8
+ MAX_SEQ: Integer
9
+ MIN_INC: Integer
10
+ MAX_INC: Integer
11
+ INC: Integer
12
+
13
+ @prand: Random
14
+ @seq: Integer
15
+ @inc: Integer
16
+ @prefix: String
17
+
18
+ def next: () -> String
19
+
20
+ def randomize_prefix!: () -> String
21
+
22
+ private
23
+
24
+ def reset_sequential!: () -> Integer
25
+
26
+ # class << self
27
+ @@nuid: NUID
28
+
29
+ def self.next: () -> String
30
+ # end class << self
31
+ end
32
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nats-pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Waldemar Quevedo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-07 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: concurrent-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
13
27
  description: NATS is an open-source, high-performance, lightweight cloud messaging
14
28
  system.
15
29
  email:
@@ -18,6 +32,8 @@ executables: []
18
32
  extensions: []
19
33
  extra_rdoc_files: []
20
34
  files:
35
+ - LICENSE
36
+ - README.md
21
37
  - lib/nats.rb
22
38
  - lib/nats/client.rb
23
39
  - lib/nats/io/client.rb
@@ -44,9 +60,38 @@ files:
44
60
  - lib/nats/io/kv/manager.rb
45
61
  - lib/nats/io/msg.rb
46
62
  - lib/nats/io/parser.rb
63
+ - lib/nats/io/rails.rb
47
64
  - lib/nats/io/subscription.rb
48
65
  - lib/nats/io/version.rb
66
+ - lib/nats/io/websocket.rb
49
67
  - lib/nats/nuid.rb
68
+ - sig/nats/io/client.rbs
69
+ - sig/nats/io/errors.rbs
70
+ - sig/nats/io/jetstream.rbs
71
+ - sig/nats/io/jetstream/api.rbs
72
+ - sig/nats/io/jetstream/errors.rbs
73
+ - sig/nats/io/jetstream/js.rbs
74
+ - sig/nats/io/jetstream/js/config.rbs
75
+ - sig/nats/io/jetstream/js/header.rbs
76
+ - sig/nats/io/jetstream/js/status.rbs
77
+ - sig/nats/io/jetstream/js/sub.rbs
78
+ - sig/nats/io/jetstream/manager.rbs
79
+ - sig/nats/io/jetstream/msg.rbs
80
+ - sig/nats/io/jetstream/msg/ack.rbs
81
+ - sig/nats/io/jetstream/msg/ack_methods.rbs
82
+ - sig/nats/io/jetstream/msg/metadata.rbs
83
+ - sig/nats/io/jetstream/pull_subscription.rbs
84
+ - sig/nats/io/jetstream/push_subscription.rbs
85
+ - sig/nats/io/kv.rbs
86
+ - sig/nats/io/kv/api.rbs
87
+ - sig/nats/io/kv/bucket_status.rbs
88
+ - sig/nats/io/kv/errors.rbs
89
+ - sig/nats/io/kv/manager.rbs
90
+ - sig/nats/io/msg.rbs
91
+ - sig/nats/io/parser.rbs
92
+ - sig/nats/io/subscription.rbs
93
+ - sig/nats/io/version.rbs
94
+ - sig/nats/nuid.rbs
50
95
  homepage: https://nats.io
51
96
  licenses:
52
97
  - Apache-2.0
@@ -66,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
111
  - !ruby/object:Gem::Version
67
112
  version: '0'
68
113
  requirements: []
69
- rubygems_version: 3.3.3
114
+ rubygems_version: 3.4.1
70
115
  signing_key:
71
116
  specification_version: 4
72
117
  summary: NATS is an open-source, high-performance, lightweight cloud messaging system.