prefab-cloud-ruby 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ebf0d2d3dfa86a3991010f99ed002bb7125fc37
4
- data.tar.gz: 042f583a1b800bc1452d9ac187b2c949849e7651
3
+ metadata.gz: aa167019e6d70cdde48a87afc80b4363eca3d3d9
4
+ data.tar.gz: 761b554954582f17a31ab902bd02eb6b856df250
5
5
  SHA512:
6
- metadata.gz: f7a1f5fafc6e0e6b5446abb903753593dc2fca8c02c71d50522d12674fb393ed0de77995772fbb22dc7cf29957b66b2ccfc7262d130e742e3f6d9c3fbefd8d6e
7
- data.tar.gz: 13ae283ac75b64dd467b19e87fb255c9fc8d4b141ea96abae6ad4de4f48f03ea93d57d8055ae56a8864edb795482c7e43d78deca175b088644bdb9b0b134b05e
6
+ metadata.gz: 0cdfd19ee6df21bddb493d4cfbf95434c6d5c3d89065c115465db6a3298caff128a5734fae7dee0df26fe1e113229710b2371324afa7b1472b347eebc26fe7e1
7
+ data.tar.gz: f5945febd993742430b3ff909d3d27d306d171e542bd336408a70adfea705267e46f12c95eb0bb4cb411154e276dd808b1a84a55e214e9d735d94797534b0916
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ grpc_tools_ruby_protoc -I ../prefab-cloud/ --ruby_out=lib --grpc_out=lib prefab.proto
@@ -3,7 +3,6 @@ require 'concurrent'
3
3
  require 'openssl'
4
4
  require 'prefab_pb'
5
5
  require 'prefab_services_pb'
6
- require 'ratelimit_pb'
7
6
  require 'prefab/config_loader'
8
7
  require 'prefab/config_resolver'
9
8
  require 'prefab/client'
@@ -48,11 +48,15 @@ module Prefab
48
48
 
49
49
  def ssl_certs
50
50
  ssl_certs = ""
51
- Dir.foreach(OpenSSL::X509::DEFAULT_CERT_DIR) do |cert|
52
- next if cert == '.' or cert == '..'
51
+ Dir["#{OpenSSL::X509::DEFAULT_CERT_DIR}/*.pem"].each do |cert|
53
52
  ssl_certs << File.open(cert).read
54
53
  end
55
- ssl_certs << File.open(OpenSSL::X509::DEFAULT_CERT_FILE).read
54
+ if OpenSSL::X509::DEFAULT_CERT_FILE && File.exists?(OpenSSL::X509::DEFAULT_CERT_FILE)
55
+ ssl_certs << File.open(OpenSSL::X509::DEFAULT_CERT_FILE).read
56
+ end
57
+ ssl_certs
58
+ rescue => e
59
+ @logger.warn("Issue loading SSL certs #{e.message}")
56
60
  ssl_certs
57
61
  end
58
62
 
@@ -15,10 +15,10 @@ module Prefab
15
15
  expiry = @client.shared_cache.read(expiry_cache_key)
16
16
  if !expiry.nil? && Integer(expiry) > Time.now.utc.to_f * 1000
17
17
  @client.stats.increment("prefab.ratelimit.limitcheck.expirycache.hit", tags: [])
18
- return It::Ratelim::Data::LimitResponse.new(passed: false, amount: 0)
18
+ return Prefab::LimitResponse.new(passed: false, amount: 0)
19
19
  end
20
20
 
21
- req = It::Ratelim::Data::LimitRequest.new(
21
+ req = Prefab::LimitRequest.new(
22
22
  account_id: @client.account_id,
23
23
  acquire_amount: acquire_amount,
24
24
  groups: groups,
@@ -35,20 +35,21 @@ module Prefab
35
35
  result
36
36
 
37
37
  rescue => e
38
- handle_error(e, on_error)
38
+ handle_error(e, on_error, groups)
39
39
  end
40
40
 
41
41
  private
42
42
 
43
- def handle_error(e, on_error)
43
+ def handle_error(e, on_error, groups)
44
44
  @client.stats.increment("prefab.ratelimit.error", tags: ["type:limit"])
45
+ message = "ratelimit for #{groups} error: #{e.message}"
45
46
  case on_error
46
47
  when :log_and_pass
47
- @client.logger.warn(e)
48
- It::Ratelim::Data::LimitResponse.new(passed: true, amount: 0)
48
+ @client.logger.warn(message)
49
+ Prefab::LimitResponse.new(passed: true, amount: 0)
49
50
  when :log_and_hit
50
- @client.logger.warn(e)
51
- It::Ratelim::Data::LimitResponse.new(passed: false, amount: 0)
51
+ @client.logger.warn(message)
52
+ Prefab::LimitResponse.new(passed: false, amount: 0)
52
53
  when :throw
53
54
  raise e
54
55
  end
@@ -3,8 +3,6 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
- require 'google/protobuf/wrappers_pb'
7
- require 'ratelimit_pb'
8
6
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
7
  add_message "prefab.ConfigServicePointer" do
10
8
  optional :account_id, :int64, 1
@@ -23,12 +21,108 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
23
21
  optional :bytes, :bytes, 3
24
22
  optional :double, :double, 4
25
23
  optional :bool, :bool, 5
26
- optional :feature_flag, :message, 6, "it.ratelim.data.FeatureFlag"
24
+ optional :feature_flag, :message, 6, "prefab.FeatureFlag"
27
25
  end
28
26
  end
29
27
  add_message "prefab.ConfigDeltas" do
30
28
  repeated :deltas, :message, 1, "prefab.ConfigDelta"
31
29
  end
30
+ add_message "prefab.LimitResponse" do
31
+ optional :passed, :bool, 1
32
+ optional :expires_at, :int64, 2
33
+ optional :enforced_group, :string, 3
34
+ optional :current_bucket, :int64, 4
35
+ optional :policy_group, :string, 5
36
+ optional :policy_name, :enum, 6, "prefab.LimitResponse.LimitPolicyNames"
37
+ optional :policy_limit, :int32, 7
38
+ optional :amount, :int64, 8
39
+ optional :limit_reset_at, :int64, 9
40
+ optional :safety_level, :enum, 10, "prefab.LimitDefinition.SafetyLevel"
41
+ end
42
+ add_enum "prefab.LimitResponse.LimitPolicyNames" do
43
+ value :NOT_SET, 0
44
+ value :SECONDLY_ROLLING, 1
45
+ value :MINUTELY_ROLLING, 3
46
+ value :HOURLY_ROLLING, 5
47
+ value :DAILY_ROLLING, 7
48
+ value :MONTHLY_ROLLING, 8
49
+ value :INFINITE, 9
50
+ value :YEARLY_ROLLING, 10
51
+ end
52
+ add_message "prefab.LimitRequest" do
53
+ optional :account_id, :int64, 1
54
+ optional :acquire_amount, :int32, 2
55
+ repeated :groups, :string, 3
56
+ optional :limit_combiner, :enum, 4, "prefab.LimitRequest.LimitCombiner"
57
+ optional :allow_partial_response, :bool, 5
58
+ end
59
+ add_enum "prefab.LimitRequest.LimitCombiner" do
60
+ value :NOT_SET, 0
61
+ value :MINIMUM, 1
62
+ value :MAXIMUM, 2
63
+ end
64
+ add_message "prefab.FeatureFlag" do
65
+ optional :account_id, :int64, 1
66
+ optional :feature, :string, 2
67
+ optional :pct, :double, 3
68
+ repeated :whitelisted, :string, 4
69
+ optional :prior_feature_name, :string, 5
70
+ end
71
+ add_message "prefab.LimitDefinition" do
72
+ optional :group, :string, 1
73
+ optional :policy_name, :enum, 2, "prefab.LimitResponse.LimitPolicyNames"
74
+ optional :limit, :int32, 3
75
+ optional :burst, :int32, 4
76
+ optional :account_id, :int64, 5
77
+ optional :last_modified, :int64, 6
78
+ optional :returnable, :bool, 7
79
+ optional :safety_level, :enum, 8, "prefab.LimitDefinition.SafetyLevel"
80
+ end
81
+ add_enum "prefab.LimitDefinition.SafetyLevel" do
82
+ value :NOT_SET, 0
83
+ value :L4_BEST_EFFORT, 4
84
+ value :L5_BOMBPROOF, 5
85
+ end
86
+ add_message "prefab.LimitDefinitions" do
87
+ repeated :definitions, :message, 1, "prefab.LimitDefinition"
88
+ end
89
+ add_message "prefab.FeatureFlags" do
90
+ repeated :flags, :message, 1, "prefab.FeatureFlag"
91
+ optional :cache_expiry, :int64, 2
92
+ end
93
+ add_message "prefab.BucketWrite" do
94
+ optional :tokenBucket, :message, 1, "prefab.TokenBucket"
95
+ optional :bucket, :string, 2
96
+ end
97
+ add_message "prefab.TokenBucket" do
98
+ optional :current_value, :int64, 1
99
+ optional :time_key, :int64, 2
100
+ repeated :expiries, :int64, 3
101
+ end
102
+ add_message "prefab.BufferedRequest" do
103
+ optional :account_id, :int64, 1
104
+ optional :method, :string, 2
105
+ optional :uri, :string, 3
106
+ optional :body, :string, 4
107
+ repeated :limit_groups, :string, 5
108
+ optional :content_type, :string, 6
109
+ optional :fifo, :bool, 7
110
+ end
111
+ add_message "prefab.BatchRequest" do
112
+ optional :account_id, :int64, 1
113
+ optional :method, :string, 2
114
+ optional :uri, :string, 3
115
+ optional :body, :string, 4
116
+ repeated :limit_groups, :string, 5
117
+ optional :batch_template, :string, 6
118
+ optional :batch_separator, :string, 7
119
+ end
120
+ add_enum "prefab.OnFailure" do
121
+ value :NOT_SET, 0
122
+ value :LOG_AND_PASS, 1
123
+ value :LOG_AND_FAIL, 2
124
+ value :THROW, 3
125
+ end
32
126
  end
33
127
 
34
128
  module Prefab
@@ -36,4 +130,18 @@ module Prefab
36
130
  ConfigDelta = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigDelta").msgclass
37
131
  ConfigValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigValue").msgclass
38
132
  ConfigDeltas = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigDeltas").msgclass
133
+ LimitResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse").msgclass
134
+ LimitResponse::LimitPolicyNames = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse.LimitPolicyNames").enummodule
135
+ LimitRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest").msgclass
136
+ LimitRequest::LimitCombiner = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest.LimitCombiner").enummodule
137
+ FeatureFlag = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlag").msgclass
138
+ LimitDefinition = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition").msgclass
139
+ LimitDefinition::SafetyLevel = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition.SafetyLevel").enummodule
140
+ LimitDefinitions = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinitions").msgclass
141
+ FeatureFlags = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlags").msgclass
142
+ BucketWrite = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BucketWrite").msgclass
143
+ TokenBucket = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.TokenBucket").msgclass
144
+ BufferedRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BufferedRequest").msgclass
145
+ BatchRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BatchRequest").msgclass
146
+ OnFailure = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.OnFailure").enummodule
39
147
  end
@@ -14,7 +14,7 @@ module Prefab
14
14
  self.unmarshal_class_method = :decode
15
15
  self.service_name = 'prefab.RateLimitService'
16
16
 
17
- rpc :LimitCheck, It::Ratelim::Data::LimitRequest, It::Ratelim::Data::LimitResponse
17
+ rpc :LimitCheck, LimitRequest, LimitResponse
18
18
  end
19
19
 
20
20
  Stub = Service.rpc_stub_class
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: prefab-cloud-ruby 0.0.6 ruby lib
5
+ # stub: prefab-cloud-ruby 0.0.7 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "prefab-cloud-ruby".freeze
9
- s.version = "0.0.6"
9
+ s.version = "0.0.7"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "LICENSE.txt",
25
25
  "Rakefile",
26
26
  "VERSION",
27
+ "compile_protos.sh",
27
28
  "lib/prefab-cloud-ruby.rb",
28
29
  "lib/prefab/auth_interceptor.rb",
29
30
  "lib/prefab/client.rb",
@@ -36,7 +37,6 @@ Gem::Specification.new do |s|
36
37
  "lib/prefab/store.rb",
37
38
  "lib/prefab_pb.rb",
38
39
  "lib/prefab_services_pb.rb",
39
- "lib/ratelimit_pb.rb",
40
40
  "prefab-cloud-ruby.gemspec"
41
41
  ]
42
42
  s.homepage = "http://github.com/prefab-cloud/prefab-cloud-ruby".freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefab-cloud-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
@@ -141,6 +141,7 @@ files:
141
141
  - LICENSE.txt
142
142
  - Rakefile
143
143
  - VERSION
144
+ - compile_protos.sh
144
145
  - lib/prefab-cloud-ruby.rb
145
146
  - lib/prefab/auth_interceptor.rb
146
147
  - lib/prefab/client.rb
@@ -153,7 +154,6 @@ files:
153
154
  - lib/prefab/store.rb
154
155
  - lib/prefab_pb.rb
155
156
  - lib/prefab_services_pb.rb
156
- - lib/ratelimit_pb.rb
157
157
  - prefab-cloud-ruby.gemspec
158
158
  homepage: http://github.com/prefab-cloud/prefab-cloud-ruby
159
159
  licenses:
@@ -1,125 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: ratelimit.proto
3
-
4
- require 'google/protobuf'
5
-
6
- require 'google/protobuf/wrappers_pb'
7
- Google::Protobuf::DescriptorPool.generated_pool.build do
8
- add_message "it.ratelim.data.LimitResponse" do
9
- optional :passed, :bool, 1
10
- optional :expires_at, :int64, 2
11
- optional :enforced_group, :string, 3
12
- optional :current_bucket, :int64, 4
13
- optional :policy_group, :string, 5
14
- optional :policy_name, :enum, 6, "it.ratelim.data.LimitResponse.LimitPolicyNames"
15
- optional :policy_limit, :int32, 7
16
- optional :amount, :int64, 8
17
- optional :limit_reset_at, :int64, 9
18
- optional :safety_level, :enum, 10, "it.ratelim.data.LimitDefinition.SafetyLevel"
19
- end
20
- add_enum "it.ratelim.data.LimitResponse.LimitPolicyNames" do
21
- value :NOT_SET, 0
22
- value :SECONDLY_ROLLING, 1
23
- value :MINUTELY_ROLLING, 3
24
- value :HOURLY_ROLLING, 5
25
- value :DAILY_ROLLING, 7
26
- value :MONTHLY_ROLLING, 8
27
- value :INFINITE, 9
28
- value :YEARLY_ROLLING, 10
29
- end
30
- add_message "it.ratelim.data.LimitRequest" do
31
- optional :account_id, :int64, 1
32
- optional :acquire_amount, :int32, 2
33
- repeated :groups, :string, 3
34
- optional :limit_combiner, :enum, 4, "it.ratelim.data.LimitRequest.LimitCombiner"
35
- optional :allow_partial_response, :bool, 5
36
- end
37
- add_enum "it.ratelim.data.LimitRequest.LimitCombiner" do
38
- value :NOT_SET, 0
39
- value :MINIMUM, 1
40
- value :MAXIMUM, 2
41
- end
42
- add_message "it.ratelim.data.FeatureFlag" do
43
- optional :account_id, :int64, 1
44
- optional :feature, :string, 2
45
- optional :pct, :double, 3
46
- repeated :whitelisted, :string, 4
47
- optional :prior_feature_name, :string, 5
48
- end
49
- add_message "it.ratelim.data.LimitDefinition" do
50
- optional :group, :string, 1
51
- optional :policy_name, :enum, 2, "it.ratelim.data.LimitResponse.LimitPolicyNames"
52
- optional :limit, :int32, 3
53
- optional :burst, :int32, 4
54
- optional :account_id, :int64, 5
55
- optional :last_modified, :int64, 6
56
- optional :returnable, :bool, 7
57
- optional :safety_level, :enum, 8, "it.ratelim.data.LimitDefinition.SafetyLevel"
58
- end
59
- add_enum "it.ratelim.data.LimitDefinition.SafetyLevel" do
60
- value :NOT_SET, 0
61
- value :L4_BEST_EFFORT, 4
62
- value :L5_BOMBPROOF, 5
63
- end
64
- add_message "it.ratelim.data.LimitDefinitions" do
65
- repeated :definitions, :message, 1, "it.ratelim.data.LimitDefinition"
66
- end
67
- add_message "it.ratelim.data.FeatureFlags" do
68
- repeated :flags, :message, 1, "it.ratelim.data.FeatureFlag"
69
- optional :cache_expiry, :int64, 2
70
- end
71
- add_message "it.ratelim.data.BucketWrite" do
72
- optional :tokenBucket, :message, 1, "it.ratelim.data.TokenBucket"
73
- optional :bucket, :string, 2
74
- end
75
- add_message "it.ratelim.data.TokenBucket" do
76
- optional :current_value, :int64, 1
77
- optional :time_key, :int64, 2
78
- repeated :expiries, :int64, 3
79
- end
80
- add_message "it.ratelim.data.BufferedRequest" do
81
- optional :account_id, :int64, 1
82
- optional :method, :string, 2
83
- optional :uri, :string, 3
84
- optional :body, :string, 4
85
- repeated :limit_groups, :string, 5
86
- optional :content_type, :string, 6
87
- optional :fifo, :bool, 7
88
- end
89
- add_message "it.ratelim.data.BatchRequest" do
90
- optional :account_id, :int64, 1
91
- optional :method, :string, 2
92
- optional :uri, :string, 3
93
- optional :body, :string, 4
94
- repeated :limit_groups, :string, 5
95
- optional :batch_template, :string, 6
96
- optional :batch_separator, :string, 7
97
- end
98
- add_enum "it.ratelim.data.OnFailure" do
99
- value :NOT_SET, 0
100
- value :LOG_AND_PASS, 1
101
- value :LOG_AND_FAIL, 2
102
- value :THROW, 3
103
- end
104
- end
105
-
106
- module It
107
- module Ratelim
108
- module Data
109
- LimitResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitResponse").msgclass
110
- LimitResponse::LimitPolicyNames = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitResponse.LimitPolicyNames").enummodule
111
- LimitRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitRequest").msgclass
112
- LimitRequest::LimitCombiner = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitRequest.LimitCombiner").enummodule
113
- FeatureFlag = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.FeatureFlag").msgclass
114
- LimitDefinition = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitDefinition").msgclass
115
- LimitDefinition::SafetyLevel = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitDefinition.SafetyLevel").enummodule
116
- LimitDefinitions = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.LimitDefinitions").msgclass
117
- FeatureFlags = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.FeatureFlags").msgclass
118
- BucketWrite = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.BucketWrite").msgclass
119
- TokenBucket = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.TokenBucket").msgclass
120
- BufferedRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.BufferedRequest").msgclass
121
- BatchRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.BatchRequest").msgclass
122
- OnFailure = Google::Protobuf::DescriptorPool.generated_pool.lookup("it.ratelim.data.OnFailure").enummodule
123
- end
124
- end
125
- end