polyn 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/Gemfile.lock +16 -5
- data/README.md +6 -9
- data/lib/cloud-event-schema.json +41 -43
- data/lib/polyn/event.rb +10 -19
- data/lib/polyn/nats.rb +2 -0
- data/lib/polyn/pull_subscriber.rb +27 -11
- data/lib/polyn/tracing.rb +81 -0
- data/lib/polyn/version.rb +1 -1
- data/lib/polyn.rb +37 -17
- data/polyn.gemspec +2 -2
- metadata +8 -11
- data/.github/workflows/ruby.yml +0 -39
- data/CODE_OF_CONDUCT.md +0 -84
- data/LICENSE.txt +0 -21
- data/docker-compose.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aef622abe4519af5e7b87f1fcd0416183829c8e4a974143d0043a5152c0a46bc
|
4
|
+
data.tar.gz: 52ed88386aff72d31461492875f9af2239ac4105dd2c2d11f7a3867c9867ec54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a51ddc4365ec85ad861498477f6ba17eb10b5dede8f06f58dea297a930f0adcaee150b9cc30c11c8ea26071db54804d1f664827a31e8f3faa085421e59c5dff1
|
7
|
+
data.tar.gz: 5e2add1f818b85ea73317fd73861f25d1ace5a91a18706863d19bfa6a4d156692ca4771232dba61a8fe8b170f00a8dfa34ffa5bfb39daab018301b94ed92855e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
polyn (0.
|
4
|
+
polyn (0.3.1)
|
5
5
|
json_schemer (~> 0.2)
|
6
6
|
nats-pure (~> 2.0)
|
7
|
-
|
7
|
+
opentelemetry-api (~> 1.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -21,6 +21,18 @@ GEM
|
|
21
21
|
regexp_parser (~> 2.0)
|
22
22
|
uri_template (~> 0.7)
|
23
23
|
nats-pure (2.1.2)
|
24
|
+
opentelemetry-api (1.1.0)
|
25
|
+
opentelemetry-common (0.19.6)
|
26
|
+
opentelemetry-api (~> 1.0)
|
27
|
+
opentelemetry-registry (0.2.0)
|
28
|
+
opentelemetry-api (~> 1.1)
|
29
|
+
opentelemetry-sdk (1.2.0)
|
30
|
+
opentelemetry-api (~> 1.1)
|
31
|
+
opentelemetry-common (~> 0.19.3)
|
32
|
+
opentelemetry-registry (~> 0.2)
|
33
|
+
opentelemetry-semantic_conventions
|
34
|
+
opentelemetry-semantic_conventions (1.8.0)
|
35
|
+
opentelemetry-api (~> 1.0)
|
24
36
|
parallel (1.21.0)
|
25
37
|
parser (3.0.2.0)
|
26
38
|
ast (~> 2.4.1)
|
@@ -62,9 +74,6 @@ GEM
|
|
62
74
|
timecop (0.9.4)
|
63
75
|
unicode-display_width (2.1.0)
|
64
76
|
uri_template (0.7.0)
|
65
|
-
webrick (1.7.0)
|
66
|
-
yard (0.9.28)
|
67
|
-
webrick (~> 1.7.0)
|
68
77
|
|
69
78
|
PLATFORMS
|
70
79
|
arm64-darwin-20
|
@@ -75,6 +84,8 @@ PLATFORMS
|
|
75
84
|
DEPENDENCIES
|
76
85
|
json_schemer
|
77
86
|
nats-pure (~> 2.0)
|
87
|
+
opentelemetry-api (~> 1.1)
|
88
|
+
opentelemetry-sdk (~> 1.2)
|
78
89
|
polyn!
|
79
90
|
rake (~> 13.0)
|
80
91
|
rspec (~> 3.0)
|
data/README.md
CHANGED
@@ -78,15 +78,6 @@ Add `:source` to make the `source` of the event more specific
|
|
78
78
|
polyn.publish("user.created.v1", { name: "Mary" }, source: "new.users")
|
79
79
|
```
|
80
80
|
|
81
|
-
Add `:triggered_by` to add a triggering event to the `polyntrace`
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
polyn = Polyn.connect(nats)
|
85
|
-
|
86
|
-
event = Polyn::Event.new
|
87
|
-
polyn.publish("user.created.v1", { name: "Mary" }, triggered_by: event)
|
88
|
-
```
|
89
|
-
|
90
81
|
You can also include options of `:header` and/or `:reply_to` to passthrough to NATS
|
91
82
|
|
92
83
|
### Consuming a Stream
|
@@ -165,6 +156,12 @@ Despite mocking some NATS functionality you will still need a running nats-serve
|
|
165
156
|
When the tests start it will load all your schemas. The tests themselves will also use the running server to verify
|
166
157
|
stream and consumer configuration information. This hybrid mocking approach is intended to give isolation and reliability while also ensuring correct integration.
|
167
158
|
|
159
|
+
## Observability
|
160
|
+
|
161
|
+
### Tracing
|
162
|
+
|
163
|
+
Polyn uses [OpenTelemetry](https://opentelemetry.io/) to create distributed traces that will connect sent and received events in different services. Your application will need the [`opentelemetry-sdk` gem](https://opentelemetry.io/docs/instrumentation/ruby/getting-started/) installed to collect the trace information.
|
164
|
+
|
168
165
|
## Development
|
169
166
|
|
170
167
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
data/lib/cloud-event-schema.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"source": {
|
14
14
|
"description": "Identifies the context in which an event happened.",
|
15
15
|
"$ref": "#/definitions/sourcedef",
|
16
|
-
"examples"
|
16
|
+
"examples": [
|
17
17
|
"https://github.com/cloudevents",
|
18
18
|
"mailto:cncf-wg-serverless@lists.cncf.io",
|
19
19
|
"urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66",
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"type": {
|
33
33
|
"description": "Describes the type of event related to the originating occurrence.",
|
34
34
|
"$ref": "#/definitions/typedef",
|
35
|
-
"examples"
|
35
|
+
"examples": [
|
36
36
|
"com.github.pull_request.opened",
|
37
37
|
"com.example.object.deleted.v2"
|
38
38
|
]
|
@@ -89,22 +89,14 @@
|
|
89
89
|
"clientversion": "0.1.0"
|
90
90
|
}
|
91
91
|
]
|
92
|
-
},
|
93
|
-
"polyntrace": {
|
94
|
-
"$ref": "#/definitions/polyntracedef",
|
95
|
-
"description": "Previous events that led to this one",
|
96
|
-
"examples": [
|
97
|
-
[
|
98
|
-
{
|
99
|
-
"type": "<topic>",
|
100
|
-
"time": "2018-04-05T17:31:00Z",
|
101
|
-
"id": "<uuid>"
|
102
|
-
}
|
103
|
-
]
|
104
|
-
]
|
105
92
|
}
|
106
93
|
},
|
107
|
-
"required": [
|
94
|
+
"required": [
|
95
|
+
"id",
|
96
|
+
"source",
|
97
|
+
"specversion",
|
98
|
+
"type"
|
99
|
+
],
|
108
100
|
"definitions": {
|
109
101
|
"iddef": {
|
110
102
|
"type": "string",
|
@@ -124,28 +116,50 @@
|
|
124
116
|
"minLength": 1
|
125
117
|
},
|
126
118
|
"datacontenttypedef": {
|
127
|
-
"type": [
|
119
|
+
"type": [
|
120
|
+
"string",
|
121
|
+
"null"
|
122
|
+
],
|
128
123
|
"minLength": 1
|
129
124
|
},
|
130
125
|
"dataschemadef": {
|
131
|
-
"type": [
|
126
|
+
"type": [
|
127
|
+
"string",
|
128
|
+
"null"
|
129
|
+
],
|
132
130
|
"format": "uri",
|
133
131
|
"minLength": 1
|
134
132
|
},
|
135
133
|
"subjectdef": {
|
136
|
-
"type": [
|
134
|
+
"type": [
|
135
|
+
"string",
|
136
|
+
"null"
|
137
|
+
],
|
137
138
|
"minLength": 1
|
138
139
|
},
|
139
140
|
"timedef": {
|
140
|
-
"type": [
|
141
|
+
"type": [
|
142
|
+
"string",
|
143
|
+
"null"
|
144
|
+
],
|
141
145
|
"format": "date-time",
|
142
146
|
"minLength": 1
|
143
147
|
},
|
144
148
|
"datadef": {
|
145
|
-
"type": [
|
149
|
+
"type": [
|
150
|
+
"object",
|
151
|
+
"string",
|
152
|
+
"number",
|
153
|
+
"array",
|
154
|
+
"boolean",
|
155
|
+
"null"
|
156
|
+
]
|
146
157
|
},
|
147
158
|
"data_base64def": {
|
148
|
-
"type": [
|
159
|
+
"type": [
|
160
|
+
"string",
|
161
|
+
"null"
|
162
|
+
],
|
149
163
|
"contentEncoding": "base64"
|
150
164
|
},
|
151
165
|
"polyndatadef": {
|
@@ -161,27 +175,11 @@
|
|
161
175
|
"type": "string"
|
162
176
|
}
|
163
177
|
},
|
164
|
-
"required": [
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
"type": "object",
|
170
|
-
"properties": {
|
171
|
-
"type": {
|
172
|
-
"type": "string"
|
173
|
-
},
|
174
|
-
"time": {
|
175
|
-
"type": "string",
|
176
|
-
"format": "date-time"
|
177
|
-
},
|
178
|
-
"id" : {
|
179
|
-
"type": "string",
|
180
|
-
"format": "uuid"
|
181
|
-
}
|
182
|
-
},
|
183
|
-
"required": ["type", "time", "id"]
|
184
|
-
}
|
178
|
+
"required": [
|
179
|
+
"clientlang",
|
180
|
+
"clientlangversion",
|
181
|
+
"clientversion"
|
182
|
+
]
|
185
183
|
}
|
186
184
|
}
|
187
185
|
}
|
data/lib/polyn/event.rb
CHANGED
@@ -76,7 +76,6 @@ module Polyn
|
|
76
76
|
@time = hash.fetch(:time, Time.now.utc.iso8601)
|
77
77
|
@data = hash.fetch(:data)
|
78
78
|
@datacontenttype = hash.fetch(:datacontenttype, "application/json")
|
79
|
-
@polyntrace = self.class.build_polyntrace(hash[:triggered_by])
|
80
79
|
@polyndata = {
|
81
80
|
clientlang: "ruby",
|
82
81
|
clientlangversion: RUBY_VERSION,
|
@@ -93,7 +92,6 @@ module Polyn
|
|
93
92
|
"time" => time,
|
94
93
|
"data" => Utils::Hash.deep_stringify_keys(data),
|
95
94
|
"datacontenttype" => datacontenttype,
|
96
|
-
"polyntrace" => Utils::Hash.deep_stringify_keys(polyntrace),
|
97
95
|
"polyndata" => Utils::Hash.deep_stringify_keys(polyndata),
|
98
96
|
}
|
99
97
|
end
|
@@ -101,15 +99,20 @@ module Polyn
|
|
101
99
|
##
|
102
100
|
# Get the Event `source` prefixed with reverse domain name
|
103
101
|
def self.full_source(source = nil)
|
104
|
-
root
|
105
|
-
|
102
|
+
root = Polyn.configuration.source_root
|
103
|
+
parts = [domain, root]
|
104
|
+
combine = lambda do |items|
|
105
|
+
items.map { |part| Polyn::Naming.dot_to_colon(part) }.join(":")
|
106
|
+
end
|
107
|
+
name = combine.call(parts)
|
106
108
|
|
107
109
|
if source
|
108
110
|
Polyn::Naming.validate_source_name!(source)
|
109
|
-
|
110
|
-
|
111
|
-
name
|
111
|
+
source = source.gsub(/(#{name}){1}:?/, "")
|
112
|
+
parts << source unless source.empty?
|
112
113
|
end
|
114
|
+
|
115
|
+
combine.call(parts)
|
113
116
|
end
|
114
117
|
|
115
118
|
##
|
@@ -119,18 +122,6 @@ module Polyn
|
|
119
122
|
"#{domain}.#{Polyn::Naming.trim_domain_prefix(type)}"
|
120
123
|
end
|
121
124
|
|
122
|
-
##
|
123
|
-
# Use a triggering event to build the polyntrace of a new event
|
124
|
-
def self.build_polyntrace(triggered_by)
|
125
|
-
return [] unless triggered_by
|
126
|
-
|
127
|
-
triggered_by.polyntrace.concat([{
|
128
|
-
id: triggered_by.id,
|
129
|
-
type: triggered_by.type,
|
130
|
-
time: triggered_by.time,
|
131
|
-
}])
|
132
|
-
end
|
133
|
-
|
134
125
|
def self.domain
|
135
126
|
Polyn.configuration.domain
|
136
127
|
end
|
data/lib/polyn/nats.rb
CHANGED
@@ -11,8 +11,7 @@ module Polyn
|
|
11
11
|
# is more than the `source_root`
|
12
12
|
def initialize(fields)
|
13
13
|
@nats = fields.fetch(:nats)
|
14
|
-
@type = fields.fetch(:type)
|
15
|
-
@type = Polyn::Naming.trim_domain_prefix(@type)
|
14
|
+
@type = Polyn::Naming.trim_domain_prefix(fields.fetch(:type))
|
16
15
|
@consumer_name = Polyn::Naming.consumer_name(@type, fields[:source])
|
17
16
|
@stream = @nats.jetstream.find_stream_name_by_subject(@type)
|
18
17
|
self.class.validate_consumer_exists!(@nats, @stream, @consumer_name)
|
@@ -39,18 +38,35 @@ module Polyn
|
|
39
38
|
# @option params [Float] :timeout Duration of the fetch request before it expires.
|
40
39
|
# @return [Array<NATS::Msg>]
|
41
40
|
def fetch(batch = 1, params = {})
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
Polyn::Tracing.processing_span(@type) do |process_span|
|
42
|
+
msgs = @psub.fetch(batch, params)
|
43
|
+
msgs.map do |msg|
|
44
|
+
Polyn::Tracing.subscribe_span(@type, msg, links: [process_span]) do |span|
|
45
|
+
updated_msg = process_message(msg)
|
46
|
+
Polyn::Tracing.span_attributes(span,
|
47
|
+
nats: @nats,
|
48
|
+
type: @type,
|
49
|
+
event: updated_msg.data,
|
50
|
+
payload: msg.data)
|
51
|
+
updated_msg
|
52
|
+
end
|
49
53
|
end
|
54
|
+
end
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
57
|
+
private
|
58
|
+
|
59
|
+
def process_message(msg)
|
60
|
+
msg = msg.clone
|
61
|
+
msg = Polyn::Nats::Msg.new(msg)
|
62
|
+
event = @serializer.deserialize(msg.data)
|
63
|
+
if event.is_a?(Polyn::Errors::Error)
|
64
|
+
msg.term
|
65
|
+
raise event
|
53
66
|
end
|
67
|
+
|
68
|
+
msg.data = event
|
69
|
+
msg
|
54
70
|
end
|
55
71
|
end
|
56
72
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Polyn
|
4
|
+
##
|
5
|
+
# Methods to enable distributed tracing across services
|
6
|
+
# Attempts to follow OpenTelemetry conventions
|
7
|
+
# https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/messaging/
|
8
|
+
class Tracing
|
9
|
+
##
|
10
|
+
# Tracer object to use to start a trace
|
11
|
+
def self.tracer
|
12
|
+
::OpenTelemetry.tracer_provider.tracer("polyn", Polyn::VERSION)
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Common attributes to add to a span involving an individual message
|
17
|
+
# https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/messaging/#messaging-attributes
|
18
|
+
def self.span_attributes(span, nats:, type:, event:, payload:)
|
19
|
+
span.add_attributes({
|
20
|
+
"messaging.system" => "NATS",
|
21
|
+
"messaging.destination" => type,
|
22
|
+
"messaging.protocol" => "Polyn",
|
23
|
+
"messaging.url" => nats.uri.to_s,
|
24
|
+
"messaging.message_id" => event.id,
|
25
|
+
"messaging.message_payload_size_bytes" => payload.bytesize,
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Uses the message header to extract trace information from the
|
31
|
+
# published message so the subscription handler can use it as
|
32
|
+
# the parent span. This will allow us to create a distributed
|
33
|
+
# trace between publications and subscriptions. It's expecting a
|
34
|
+
# `traceparent` header to be set on the message
|
35
|
+
# https://www.w3.org/TR/trace-context/#traceparent-header
|
36
|
+
def self.connect_span_with_received_message(msg, &block)
|
37
|
+
context = OpenTelemetry.propagation.extract(msg.header)
|
38
|
+
::OpenTelemetry::Context.with_current(context, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Add a `traceparent` header to the headers for a message so that the
|
43
|
+
# subscribers can be connected with it
|
44
|
+
# https://www.w3.org/TR/trace-context/#traceparent-header
|
45
|
+
def self.trace_header(headers = {})
|
46
|
+
::OpenTelemetry.propagation.inject(headers)
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Start a span for publishing an event
|
51
|
+
def self.publish_span(type, &block)
|
52
|
+
tracer.in_span("#{type} send", kind: "PRODUCER", &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Start a span for handling a received event
|
57
|
+
def self.subscribe_span(type, msg, links: nil, &block)
|
58
|
+
connect_span_with_received_message(msg) do
|
59
|
+
tracer.in_span("#{type} receive", kind: "CONSUMER", links: convert_links(links), &block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Start a span to handle processing of batch messages
|
65
|
+
def self.processing_span(type, &block)
|
66
|
+
tracer.in_span("#{type} process", kind: "CONSUMER", &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
private
|
71
|
+
|
72
|
+
def convert_links(links)
|
73
|
+
links.map { |link| create_span_link(link) } if links
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_span_link(span)
|
77
|
+
::OpenTelemetry::Trace::Link.new(span.context)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/polyn/version.rb
CHANGED
data/lib/polyn.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require "json_schemer"
|
22
22
|
require "json"
|
23
23
|
require "nats/client"
|
24
|
+
require "opentelemetry"
|
24
25
|
require "securerandom"
|
25
26
|
|
26
27
|
require "polyn/configuration"
|
@@ -35,6 +36,7 @@ require "polyn/pull_subscriber"
|
|
35
36
|
require "polyn/schema_store"
|
36
37
|
require "polyn/serializers/json"
|
37
38
|
require "polyn/testing/mock_nats"
|
39
|
+
require "polyn/tracing"
|
38
40
|
require "polyn/utils/utils"
|
39
41
|
require "polyn/version"
|
40
42
|
|
@@ -78,27 +80,29 @@ module Polyn
|
|
78
80
|
# @param type [String] The type of event
|
79
81
|
# @param data [any] The data to include in the event
|
80
82
|
# @option options [String] :source - information to specify the source of the event
|
81
|
-
# @option options [String] :triggered_by - The event that triggered this one.
|
82
83
|
# Will use information from the event to build up the `polyntrace` data
|
83
84
|
# @option options [String] :reply_to - Reply to a specific topic
|
84
85
|
# @option options [String] :header - Headers to include in the message
|
85
86
|
def publish(type, data, **opts)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
Polyn::Tracing.publish_span(type) do |span|
|
88
|
+
event = Event.new({
|
89
|
+
type: type,
|
90
|
+
source: opts[:source],
|
91
|
+
data: data,
|
92
|
+
})
|
92
93
|
|
93
|
-
|
94
|
-
# https://docs.nats.io/using-nats/developer/develop_jetstream/model_deep_dive#message-deduplication
|
95
|
-
msg_id_header = { "Nats-Msg-Id" => event.id }
|
96
|
-
header = opts.fetch(:header, {})
|
97
|
-
header = msg_id_header.merge(header)
|
94
|
+
json = @serializer.serialize!(event)
|
98
95
|
|
99
|
-
|
96
|
+
Polyn::Tracing.span_attributes(span,
|
97
|
+
nats: @nats.nats,
|
98
|
+
type: type,
|
99
|
+
event: event,
|
100
|
+
payload: json)
|
100
101
|
|
101
|
-
|
102
|
+
header = add_headers(opts.fetch(:header, {}), event)
|
103
|
+
|
104
|
+
@nats.publish(type, json, opts[:reply_to], header: header)
|
105
|
+
end
|
102
106
|
end
|
103
107
|
|
104
108
|
## Create subscription which is dispatched asynchronously
|
@@ -111,9 +115,18 @@ module Polyn
|
|
111
115
|
# @option options [String] :pending_bytes_limit
|
112
116
|
def subscribe(type, opts = {}, &callback)
|
113
117
|
@nats.subscribe(type, opts) do |msg|
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
Polyn::Tracing.subscribe_span(type, msg) do |span|
|
119
|
+
event = @serializer.deserialize!(msg.data)
|
120
|
+
|
121
|
+
Polyn::Tracing.span_attributes(span,
|
122
|
+
nats: @nats.nats,
|
123
|
+
type: type,
|
124
|
+
event: event,
|
125
|
+
payload: msg.data)
|
126
|
+
|
127
|
+
msg.data = event
|
128
|
+
callback.call(msg)
|
129
|
+
end
|
117
130
|
end
|
118
131
|
end
|
119
132
|
|
@@ -154,5 +167,12 @@ module Polyn
|
|
154
167
|
Polyn::Nats
|
155
168
|
end
|
156
169
|
end
|
170
|
+
|
171
|
+
def add_headers(headers, event)
|
172
|
+
Polyn::Tracing.trace_header(headers)
|
173
|
+
# Ensure accidental message duplication doesn't happen
|
174
|
+
# https://docs.nats.io/using-nats/developer/develop_jetstream/model_deep_dive#message-deduplication
|
175
|
+
{ "Nats-Msg-Id" => event.id }.merge(headers)
|
176
|
+
end
|
157
177
|
end
|
158
178
|
end
|
data/polyn.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.summary = "Polyn Service Framework"
|
29
29
|
spec.description = "A lightweight reactive microservice framework."
|
30
|
-
spec.homepage = "https://github.com/
|
30
|
+
spec.homepage = "https://github.com/SpiffInc/polyn/tree/main/polyn_ruby_client"
|
31
31
|
spec.license = "MIT"
|
32
32
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
33
33
|
|
@@ -48,5 +48,5 @@ Gem::Specification.new do |spec|
|
|
48
48
|
|
49
49
|
spec.add_dependency "json_schemer", "~> 0.2"
|
50
50
|
spec.add_dependency "nats-pure", "~> 2.0"
|
51
|
-
spec.add_dependency "
|
51
|
+
spec.add_dependency "opentelemetry-api", "~> 1.1"
|
52
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarod
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_schemer
|
@@ -40,19 +40,19 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: opentelemetry-api
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '1.1'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '1.1'
|
56
56
|
description: A lightweight reactive microservice framework.
|
57
57
|
email:
|
58
58
|
- jarod.reid@spiff.com
|
@@ -61,22 +61,18 @@ executables: []
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- ".github/workflows/ruby.yml"
|
65
64
|
- ".gitignore"
|
66
65
|
- ".rspec"
|
67
66
|
- ".rubocop.yml"
|
68
67
|
- ".tool-versions"
|
69
68
|
- ".travis.yml"
|
70
69
|
- CHANGELOG.md
|
71
|
-
- CODE_OF_CONDUCT.md
|
72
70
|
- Gemfile
|
73
71
|
- Gemfile.lock
|
74
|
-
- LICENSE.txt
|
75
72
|
- README.md
|
76
73
|
- Rakefile
|
77
74
|
- bin/console
|
78
75
|
- bin/setup
|
79
|
-
- docker-compose.yml
|
80
76
|
- lib/cloud-event-schema.json
|
81
77
|
- lib/polyn.rb
|
82
78
|
- lib/polyn/cloud_event.rb
|
@@ -99,16 +95,17 @@ files:
|
|
99
95
|
- lib/polyn/testing/mock_msg.rb
|
100
96
|
- lib/polyn/testing/mock_nats.rb
|
101
97
|
- lib/polyn/testing/mock_pull_subscription.rb
|
98
|
+
- lib/polyn/tracing.rb
|
102
99
|
- lib/polyn/utils/hash.rb
|
103
100
|
- lib/polyn/utils/string.rb
|
104
101
|
- lib/polyn/utils/utils.rb
|
105
102
|
- lib/polyn/version.rb
|
106
103
|
- polyn.gemspec
|
107
|
-
homepage: https://github.com/
|
104
|
+
homepage: https://github.com/SpiffInc/polyn/tree/main/polyn_ruby_client
|
108
105
|
licenses:
|
109
106
|
- MIT
|
110
107
|
metadata:
|
111
|
-
homepage_uri: https://github.com/
|
108
|
+
homepage_uri: https://github.com/SpiffInc/polyn/tree/main/polyn_ruby_client
|
112
109
|
post_install_message:
|
113
110
|
rdoc_options: []
|
114
111
|
require_paths:
|
data/.github/workflows/ruby.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
2
|
-
# They are provided by a third-party and are governed by
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
|
-
name: Ruby
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ main ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ main ]
|
15
|
-
|
16
|
-
jobs:
|
17
|
-
test:
|
18
|
-
|
19
|
-
runs-on: ubuntu-latest
|
20
|
-
strategy:
|
21
|
-
matrix:
|
22
|
-
ruby-version: ['2.6', '2.7', '3.0']
|
23
|
-
|
24
|
-
steps:
|
25
|
-
- uses: actions/checkout@v2
|
26
|
-
- name: Start NATS Jetstream
|
27
|
-
run: docker run --rm -d --network host nats:latest -js
|
28
|
-
- name: Set up Ruby
|
29
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
30
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
31
|
-
# uses: ruby/setup-ruby@v1
|
32
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
33
|
-
with:
|
34
|
-
ruby-version: ${{ matrix.ruby-version }}
|
35
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
|
-
- name: Start containers
|
37
|
-
run: docker-compose -f "docker-compose.yml" up -d --build
|
38
|
-
- name: Run tests
|
39
|
-
run: bundle exec rspec spec
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
-
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
-
|
9
|
-
## Our Standards
|
10
|
-
|
11
|
-
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
-
|
13
|
-
* Demonstrating empathy and kindness toward other people
|
14
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
-
* Giving and gracefully accepting constructive feedback
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
-
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
-
|
19
|
-
Examples of unacceptable behavior include:
|
20
|
-
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
advances of any kind
|
23
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
-
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
address, without their explicit permission
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
-
professional setting
|
29
|
-
|
30
|
-
## Enforcement Responsibilities
|
31
|
-
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
-
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
-
|
36
|
-
## Scope
|
37
|
-
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
-
|
40
|
-
## Enforcement
|
41
|
-
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at therealfugu@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
-
|
44
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
-
|
46
|
-
## Enforcement Guidelines
|
47
|
-
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
-
|
50
|
-
### 1. Correction
|
51
|
-
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
-
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
-
|
56
|
-
### 2. Warning
|
57
|
-
|
58
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
-
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
-
|
62
|
-
### 3. Temporary Ban
|
63
|
-
|
64
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
-
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
-
|
68
|
-
### 4. Permanent Ban
|
69
|
-
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
-
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
-
|
74
|
-
## Attribution
|
75
|
-
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
-
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
-
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
-
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
82
|
-
|
83
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2021 Jarod
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|