deployagram-logger-client 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 +14 -0
- data/README.md +9 -0
- data/lib/deployagram/errors.rb +24 -0
- data/lib/deployagram/logger_client.rb +78 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4cddc12b6ee96e6b1f706876bc520c20c70b1e61197111be1530a0e3d7e654e0
|
|
4
|
+
data.tar.gz: 33cf6a641087ff16cb64d862b038e40507172aeabfdde9a571908deddfc413a0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4ae3a2ec2895559cfaa4c1ccc576cd30f8be1f279f77e4abbb585e6db572479e9bb3280e92cdec9ff8b3dc46602d385ed5e98a06afeee63c92ab303a0300b240
|
|
7
|
+
data.tar.gz: 182598502b037526580d77718c98d8d95613314cff5d009f64957710078cbecdd7b0632e7a88bce89fbd7d836da8f8847ada0b12628e2621b624ddcc3163df63
|
data/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
DEPLOYAGRAM PROPRIETARY LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Deployagram, Cookiebit and Andy Muir.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted to use this software solely for its intended purpose.
|
|
6
|
+
|
|
7
|
+
RESTRICTIONS:
|
|
8
|
+
- No modification of the software is permitted
|
|
9
|
+
- No reverse engineering, decompilation, or disassembly
|
|
10
|
+
- No redistribution without explicit written permission
|
|
11
|
+
- Source code remains proprietary and confidential
|
|
12
|
+
- Usage is limited to the compiled npm package (the distributed tarball) artifact only
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
data/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# deployagram-logger-client
|
|
2
|
+
|
|
3
|
+
Client for the Deployagram Collector's HTTP API (Ruby).
|
|
4
|
+
|
|
5
|
+
Writes interactions, sequence-diagram markers, test-run ends and Kafka records to the Deployagram Collector. It has no read call.
|
|
6
|
+
|
|
7
|
+
Depends on: none.
|
|
8
|
+
|
|
9
|
+
Part of the Deployagram Ruby packages. See `../../README.md`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Deployagram
|
|
2
|
+
# Raised when the Collector answers with a non-2xx status.
|
|
3
|
+
class CollectorError < StandardError
|
|
4
|
+
attr_reader :status
|
|
5
|
+
|
|
6
|
+
def initialize(method, path, status, body)
|
|
7
|
+
@status = status
|
|
8
|
+
super("Collector #{method.to_s.upcase} #{path} failed with HTTP #{status}#{body.empty? ? "" : ": #{body}"}")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Raised when the Proxy rejects its configuration.
|
|
13
|
+
class ProxyConfigError < StandardError
|
|
14
|
+
attr_reader :status
|
|
15
|
+
|
|
16
|
+
def initialize(status, body)
|
|
17
|
+
@status = status
|
|
18
|
+
super("Proxy rejected its configuration with HTTP #{status}#{body.empty? ? "" : ": #{body}"}")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Raised when the Collector or Proxy cannot be found or started.
|
|
23
|
+
class EnvironmentError < StandardError; end
|
|
24
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
require "json"
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
require "deployagram/errors"
|
|
6
|
+
|
|
7
|
+
module Deployagram
|
|
8
|
+
# Client for the Deployagram Collector. Mirrors the Node DiagramLoggerClient, except that it does not
|
|
9
|
+
# read logs back: the Collector is written to, and the sequence diagrams are read in the Collector's UI.
|
|
10
|
+
#
|
|
11
|
+
# Logs are plain hashes with the keys timestamp, protocol, source, target, message and body (strings).
|
|
12
|
+
class LoggerClient
|
|
13
|
+
attr_reader :base_url
|
|
14
|
+
|
|
15
|
+
def initialize(base_url:)
|
|
16
|
+
@base_url = base_url.sub(%r{/+\z}, "")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# POST /log: store one interaction.
|
|
20
|
+
def log(entry)
|
|
21
|
+
request(:post, "/log", entry)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# POST /log/markEnd/{sequenceDiagramId}: close the current sequence diagram.
|
|
25
|
+
def mark_end(sequence_diagram_id)
|
|
26
|
+
request(:post, "/log/markEnd/#{encode(sequence_diagram_id)}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# POST /run/markTestRunEnd/{containerId}/{testRunId}: end a test run and flush it, when a
|
|
30
|
+
# central logger is configured on the Collector.
|
|
31
|
+
def flush_to_cloud(container_id, test_run_id)
|
|
32
|
+
request(:post, "/run/markTestRunEnd/#{encode(container_id)}/#{encode(test_run_id)}")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# PUT /kafka/configuration: the broker the Collector reads Kafka records from. Needs runtime mode.
|
|
36
|
+
def configure_kafka_broker(bootstrap_servers)
|
|
37
|
+
request(:put, "/kafka/configuration", { "bootstrapServers" => bootstrap_servers })
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# PUT /schemaRegistry/configuration: the registry the Collector decodes records with. Needs runtime mode.
|
|
41
|
+
def configure_schema_registry(url)
|
|
42
|
+
request(:put, "/schemaRegistry/configuration", { "url" => url })
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# POST /kafka/consumer: a record was consumed. Hash keys: nameOfConsumingApp, protocol, topic, partition, offset.
|
|
46
|
+
def kafka_consumer_read(read)
|
|
47
|
+
request(:post, "/kafka/consumer", read)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# POST /kafka/producer: a record was produced and acknowledged. Hash keys: nameOfProducingApp, protocol,
|
|
51
|
+
# topic, partition, offset.
|
|
52
|
+
def kafka_producer_record(record)
|
|
53
|
+
request(:post, "/kafka/producer", record)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def encode(segment)
|
|
59
|
+
ERB::Util.url_encode(segment.to_s)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def request(method, path, body = nil)
|
|
63
|
+
uri = URI(base_url + path)
|
|
64
|
+
klass = method == :put ? Net::HTTP::Put : Net::HTTP::Post
|
|
65
|
+
req = klass.new(uri)
|
|
66
|
+
req["Accept"] = "application/json"
|
|
67
|
+
if body
|
|
68
|
+
req["Content-Type"] = "application/json"
|
|
69
|
+
req.body = JSON.generate(body)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }
|
|
73
|
+
raise CollectorError.new(method, path, res.code.to_i, res.body.to_s) unless res.is_a?(Net::HTTPSuccess)
|
|
74
|
+
|
|
75
|
+
res.body.to_s.empty? ? nil : JSON.parse(res.body)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: deployagram-logger-client
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Deployagram
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: "Writes interactions, sequence-diagram markers, test-run ends and Kafka records to the Deployagram Collector. It has no read call."
|
|
13
|
+
email:
|
|
14
|
+
- andy@deployagram.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE
|
|
20
|
+
- README.md
|
|
21
|
+
- lib/deployagram/errors.rb
|
|
22
|
+
- lib/deployagram/logger_client.rb
|
|
23
|
+
licenses:
|
|
24
|
+
- SEE LICENSE IN LICENSE
|
|
25
|
+
metadata:
|
|
26
|
+
rubygems_mfa_required: "true"
|
|
27
|
+
rdoc_options: []
|
|
28
|
+
require_paths:
|
|
29
|
+
- lib
|
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
-
|
|
33
|
+
- ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "3.2"
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
-
|
|
39
|
+
- ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: "0"
|
|
42
|
+
requirements: []
|
|
43
|
+
rubygems_version: 4.1.0
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Client for the Deployagram Collector's HTTP API (Ruby)
|
|
46
|
+
test_files: []
|