lsslog 0.1.1.pre.rc1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0b2f4d83d62f155cb54aadd1aced2ea3d9d130ecee5d6c21321d88f94196ca32
4
+ data.tar.gz: 50ac184332e751d6ee7035eb907ebb1f501d979c28aeb45021634f7dd3332a84
5
+ SHA512:
6
+ metadata.gz: b05b896c5ebb504249bf0950a4a1cc5b687d738646141948263f79427a0932c4e4bae91e1ed6907b1f6e709d83c51fa548be03d45f5994c3cccc463dddcedf95
7
+ data.tar.gz: 3ff4d324d72c8a46fc4236493407c2c72f9cab031562929accce2a723327cff0d60a06e402eadaab1efb131398c588d48a222631fcf053b5975b0afe74247338
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in lss_log.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # LssLog
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lsslog`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'lsslog'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install lsslog
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lsslog.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lss_log"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/lsslog.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'lsslog_services_pb'
2
+ require 'lsslog/version'
3
+ require 'lsslog/configuration'
4
+
5
+ require 'lsslog/services/base'
6
+ require 'lsslog/services/get_lss_config'
7
+ require 'lsslog/services/get_version'
8
+ require 'lsslog/services/remove_lss_config'
9
+ require 'lsslog/services/set_lss_config'
10
+ require 'lsslog/services/set_trans_exp_time'
11
+ require 'lsslog/services/write_log'
12
+
13
+ module Lsslog
14
+ class Error < StandardError; end
15
+
16
+ class << self
17
+ attr_writer :configuration
18
+ end
19
+
20
+ def self.configuration
21
+ @configuration ||= Configuration.new
22
+ end
23
+
24
+ def self.configure
25
+ yield(configuration)
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ module Lsslog
2
+ class Configuration
3
+ attr_accessor :lss_host
4
+
5
+ def initialize
6
+ @lss_host = nil
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ require 'grpc'
2
+ require "lsslog_services_pb"
3
+
4
+ module Lsslog
5
+ module Services
6
+ class Base
7
+ attr_reader :client
8
+
9
+ def initialize
10
+ @client = ::Lsslog::LssLogService::Stub.new(lss_host, :this_channel_is_insecure)
11
+ end
12
+
13
+ def self.call(*args)
14
+ new.call(*args)
15
+ end
16
+
17
+ private
18
+
19
+ def lss_host
20
+ @lss_host ||= ::Lsslog.configuration.lss_host
21
+ raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
22
+ @lss_host
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ module Lsslog
2
+ module Services
3
+ class GetLssConfig < Base
4
+ def call(flow_id = nil)
5
+ response = client.get_lss_config(Lsslog::LssConfig.new(flow_id: flow_id))
6
+ Rails.logger.info "GetLssConfig: #{response.to_json}"
7
+ response
8
+ rescue GRPC::BadStatus => e
9
+ Rails.logger.info "ERROR: #{e.message}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Lsslog
2
+ module Services
3
+ class GetVersion < Base
4
+ def call
5
+ response = client.get_version(Lsslog::EmptyIn.new)
6
+ Rails.logger.info "GetVersion: #{response.to_json}"
7
+ response
8
+ rescue GRPC::BadStatus => e
9
+ Rails.logger.info "ERROR: #{e.message}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Lsslog
2
+ module Services
3
+ class RemoveLssConfig < Base
4
+ def call(flow_id)
5
+ response = client.remove_lss_config(Lsslog::LssConfig.new(flow_id: flow_id))
6
+ Rails.logger.info "RemoveLssConfig: #{response.to_json}"
7
+ rescue GRPC::BadStatus => e
8
+ Rails.logger.info "ERROR: #{e.message}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Lsslog
2
+ module Services
3
+ class SetLssConfig < Base
4
+ def call(config)
5
+ response = client.set_lss_config(Lsslog::LssConfig.new(config))
6
+ Rails.logger.info "SetLssConfig: #{response.to_json}"
7
+ rescue GRPC::BadStatus => e
8
+ Rails.logger.info "ERROR: #{e.message}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Lsslog
2
+ module Services
3
+ class SetTransExpTime < Base
4
+ def call(config)
5
+ response = client.set_trans_exp_time(Lsslog::TransExpTime.new(config))
6
+ Rails.logger.info "WriteLog: #{response.to_json}"
7
+ rescue GRPC::BadStatus => e
8
+ Rails.logger.info "ERROR: #{e.message}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Lsslog
2
+ module Services
3
+ class WriteLog < Base
4
+ def call(message)
5
+ response = client.write_log(Lsslog::LssLog.new(message))
6
+ Rails.logger.info "WriteLog: #{response.to_json}"
7
+ rescue GRPC::BadStatus => e
8
+ Rails.logger.info "ERROR: #{e.message}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Lsslog
2
+ VERSION = "0.1.1-rc1"
3
+ end
data/lib/lsslog_pb.rb ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: lsslog.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file('lsslog.proto', syntax: :proto3) do
8
+ add_message 'lsslog.LssLog' do
9
+ optional :transaction_id, :string, 1
10
+ optional :flow_id, :string, 3
11
+ optional :subflow_id, :string, 4
12
+ optional :flow_dir, :enum, 2, 'lsslog.FlowDirection'
13
+ optional :flow_depth, :int32, 5
14
+ optional :system_id, :string, 6
15
+ optional :flow_body, :string, 7
16
+ optional :request_method, :string, 8
17
+ optional :request_url, :string, 9
18
+ optional :status, :int32, 10
19
+ optional :response_size, :int64, 11
20
+ optional :user_agent, :string, 12
21
+ optional :remote_ip, :string, 13
22
+ optional :server_ip, :string, 14
23
+ optional :latency, :int32, 15
24
+ optional :protocol, :string, 16
25
+ optional :start_time, :int64, 17
26
+ optional :end_time, :int64, 18
27
+ optional :created_at, :int64, 19
28
+ optional :recevied_at, :int64, 20
29
+ optional :is_completed, :bool, 21
30
+ optional :tenant_id, :string, 22
31
+ end
32
+ add_message 'lsslog.LssRes' do
33
+ optional :body, :string, 1
34
+ optional :code, :int32, 2
35
+ end
36
+ add_message 'lsslog.VersionOut' do
37
+ optional :api_verion, :string, 1
38
+ optional :branch, :string, 2
39
+ optional :commit, :string, 3
40
+ optional :date, :string, 4
41
+ optional :go_version, :string, 5
42
+ optional :os_arch, :string, 6
43
+ end
44
+ add_message 'lsslog.EmptyIn' do
45
+ end
46
+ add_message 'lsslog.TransExpTime' do
47
+ optional :flow_exp_time, :int32, 1
48
+ optional :subflow_exp_time, :int32, 2
49
+ end
50
+ add_message 'lsslog.LssConfig' do
51
+ optional :flow_id, :string, 1
52
+ optional :flow_name, :string, 2
53
+ optional :enforce_sequence, :bool, 3
54
+ optional :number_subflow, :int32, 4
55
+ end
56
+ add_message 'lsslog.LssConfigRes' do
57
+ repeated :data, :message, 1, 'lsslog.LssConfig'
58
+ optional :trans_exp_time, :message, 2, 'lsslog.TransExpTime'
59
+ end
60
+ add_enum 'lsslog.FlowDirection' do
61
+ value :REQUEST, 0
62
+ value :RESPONSE, 1
63
+ end
64
+ end
65
+ end
66
+
67
+ module Lsslog
68
+ LssLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.LssLog').msgclass
69
+ LssRes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.LssRes').msgclass
70
+ VersionOut = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.VersionOut').msgclass
71
+ EmptyIn = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.EmptyIn').msgclass
72
+ TransExpTime = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.TransExpTime').msgclass
73
+ LssConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.LssConfig').msgclass
74
+ LssConfigRes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.LssConfigRes').msgclass
75
+ FlowDirection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup('lsslog.FlowDirection').enummodule
76
+ end
@@ -0,0 +1,27 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: lsslog.proto for package 'lsslog'
3
+
4
+ require 'grpc'
5
+ require 'lsslog_pb'
6
+
7
+ module Lsslog
8
+ module LssLogService
9
+ class Service
10
+
11
+ include GRPC::GenericService
12
+
13
+ self.marshal_class_method = :encode
14
+ self.unmarshal_class_method = :decode
15
+ self.service_name = 'lsslog.LssLogService'
16
+
17
+ rpc :WriteLog, ::Lsslog::LssLog, ::Lsslog::LssRes
18
+ rpc :GetVersion, ::Lsslog::EmptyIn, ::Lsslog::VersionOut
19
+ rpc :SetLssConfig, ::Lsslog::LssConfig, ::Lsslog::LssRes
20
+ rpc :GetLssConfig, ::Lsslog::LssConfig, ::Lsslog::LssConfigRes
21
+ rpc :RemoveLssConfig, ::Lsslog::LssConfig, ::Lsslog::LssRes
22
+ rpc :SetTransExpTime, ::Lsslog::TransExpTime, ::Lsslog::LssRes
23
+ end
24
+
25
+ Stub = Service.rpc_stub_class
26
+ end
27
+ end
data/lsslog.gemspec ADDED
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "lsslog/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lsslog"
8
+ spec.version = Lsslog::VERSION
9
+ spec.authors = ["Thanh Ngo"]
10
+ spec.email = ["thanhngo@innogram.com"]
11
+
12
+ spec.summary = "Lsslog Ruby Client"
13
+ spec.description = "Lsslog Ruby Client"
14
+ spec.homepage = "https://gitlab.skylabteam.com/thanh.ngo/lsslog-ruby-client"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "https://gitlab.skylabteam.com"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.platform = Gem::Platform::RUBY
35
+
36
+ spec.add_dependency "google-protobuf", "~> 3.8.0"
37
+ spec.add_dependency "grpc", "~> 1.21"
38
+
39
+ spec.add_development_dependency "grpc-tools", "~> 1.34"
40
+ spec.add_development_dependency "bundler", "~> 1.17"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ end
data/proto/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Generate gRPC code
2
+ ```
3
+ grpc_tools_ruby_protoc -I ./proto/ --ruby_out=./lib --grpc_out=./lib ./proto/lsslog.proto
4
+
5
+ ```
@@ -0,0 +1,88 @@
1
+ syntax = "proto3";
2
+ package lsslog;
3
+
4
+ enum FlowDirection {
5
+ REQUEST = 0;
6
+ RESPONSE = 1;
7
+ }
8
+
9
+ message LssLog {
10
+ string transaction_id = 1;
11
+ string flow_id = 3;
12
+ string subflow_id = 4;
13
+ FlowDirection flow_dir = 2;
14
+ int32 flow_depth = 5;
15
+ string system_id = 6;
16
+ string flow_body = 7;
17
+ string request_method = 8;
18
+ string request_url = 9;
19
+ int32 status = 10;
20
+ int64 response_size = 11;
21
+ string user_agent = 12;
22
+ string remote_ip = 13;
23
+ string server_ip = 14;
24
+ int32 latency = 15;
25
+ string protocol = 16;
26
+ int64 start_time = 17;
27
+ int64 end_time = 18;
28
+ int64 created_at = 19;
29
+ int64 recevied_at = 20;
30
+ bool is_completed = 21;
31
+ string tenant_id = 22;
32
+ }
33
+
34
+ message LssRes {
35
+ string body = 1;
36
+ int32 code = 2;
37
+ }
38
+
39
+ message VersionOut {
40
+ string api_verion = 1;
41
+ string branch = 2;
42
+ string commit = 3;
43
+ string date = 4;
44
+ string go_version = 5;
45
+ string os_arch = 6;
46
+ }
47
+
48
+ message EmptyIn {}
49
+
50
+ // message FlowChart {
51
+ // string curr_flow_id = 1;
52
+ // string prev_flow_id = 2;
53
+ // string next_flow_id = 3;
54
+ // bool enforced_sequence = 4;
55
+ // }
56
+
57
+ // message SubFlowChart {
58
+ // int32 number_subflow = 1;
59
+ // bool enforced_sequence = 2;
60
+ // }
61
+
62
+ message TransExpTime {
63
+ int32 flow_exp_time = 1;
64
+ int32 subflow_exp_time = 2;
65
+ }
66
+
67
+ message LssConfig {
68
+ string flow_id = 1;
69
+ string flow_name = 2;
70
+ bool enforce_sequence = 3;
71
+ // FlowChart flow_chart = 3;
72
+ int32 number_subflow = 4;
73
+ // SubFlowChart subflow_chart = 4;
74
+ }
75
+
76
+ message LssConfigRes {
77
+ repeated LssConfig data = 1;
78
+ TransExpTime trans_exp_time = 2;
79
+ }
80
+
81
+ service LssLogService {
82
+ rpc WriteLog(LssLog) returns (LssRes) {};
83
+ rpc GetVersion(EmptyIn) returns (VersionOut) {};
84
+ rpc SetLssConfig(LssConfig) returns (LssRes) {};
85
+ rpc GetLssConfig(LssConfig) returns (LssConfigRes) {};
86
+ rpc RemoveLssConfig(LssConfig) returns (LssRes) {};
87
+ rpc SetTransExpTime(TransExpTime) returns (LssRes) {};
88
+ }
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lsslog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1.pre.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Thanh Ngo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-protobuf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: grpc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.21'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.21'
41
+ - !ruby/object:Gem::Dependency
42
+ name: grpc-tools
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.34'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.34'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.17'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.17'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Lsslog Ruby Client
84
+ email:
85
+ - thanhngo@innogram.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - bin/console
95
+ - bin/setup
96
+ - lib/lsslog.rb
97
+ - lib/lsslog/configuration.rb
98
+ - lib/lsslog/services/base.rb
99
+ - lib/lsslog/services/get_lss_config.rb
100
+ - lib/lsslog/services/get_version.rb
101
+ - lib/lsslog/services/remove_lss_config.rb
102
+ - lib/lsslog/services/set_lss_config.rb
103
+ - lib/lsslog/services/set_trans_exp_time.rb
104
+ - lib/lsslog/services/write_log.rb
105
+ - lib/lsslog/version.rb
106
+ - lib/lsslog_pb.rb
107
+ - lib/lsslog_services_pb.rb
108
+ - lsslog.gemspec
109
+ - proto/README.md
110
+ - proto/lsslog.proto
111
+ homepage: https://gitlab.skylabteam.com/thanh.ngo/lsslog-ruby-client
112
+ licenses: []
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">"
126
+ - !ruby/object:Gem::Version
127
+ version: 1.3.1
128
+ requirements: []
129
+ rubygems_version: 3.1.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Lsslog Ruby Client
133
+ test_files: []