strongdm 14.14.0 → 14.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0857e02b8ab13871d789565a616cc61d9bac7c46ea853fefca26d651d1527db4'
4
- data.tar.gz: 04c8e8b55916ad149689bd5a24b547f4108adff8d1c31291bc0d6dc9815b4027
3
+ metadata.gz: ffc2f684354edc591bd80a6bc6b06e5c60ba616361b52bbe4841615aa7038049
4
+ data.tar.gz: 4734c850b046b1d0a673500f38f75199396b10314c576b1fe8015db6d5ff9e17
5
5
  SHA512:
6
- metadata.gz: d3a20271170144cf5e758c2310a6d5b3aba18d688bcd8d4c7da24d3397fff329454870e672c3e29e347636f048eb9977edaf9ec01b364c8fe1d846adb6bae3e4
7
- data.tar.gz: b3c0e300ce7aee0b82f2cdc61411053459627ceb63ec05ff1a58abf74fabc73d8141507d87542a28bd30684573bdf89ad45fd7b5862ef7848d206c50b2567b22
6
+ metadata.gz: b574d54bf9023fbeb95d65992ec43a3ec8e7af1a4643ac01125e71517fc521c67605f4c243a2559c28ea34bfda1a9c628df14e71bd8163477fe019663dbdbb4c
7
+ data.tar.gz: c6e75c6c48358596a8d78428ef5e1499db065d3400e7bceddd7be4141526ea0a916e8d5c0b545a26bae42c158f39ccaeea2ee3069269279b733c36dd31e002ef
data/.git/ORIG_HEAD CHANGED
@@ -1 +1 @@
1
- 6a06ac49ca3c4d8d829450631d5f809c0fd5f593
1
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369
data/.git/index CHANGED
Binary file
data/.git/logs/HEAD CHANGED
@@ -1,3 +1,3 @@
1
- 0000000000000000000000000000000000000000 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 root <root@8a49ade2be7e.(none)> 1747236124 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
2
- 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 root <root@8a49ade2be7e.(none)> 1747236124 +0000 checkout: moving from master to master
3
- 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 208194810b58fc7e050508e7df5360b4f39d5b68 root <root@8a49ade2be7e.(none)> 1747236124 +0000 merge origin/development: Fast-forward
1
+ 0000000000000000000000000000000000000000 88d2b85cd4a760ba5f48260c9a1799a441f96369 root <root@a26af7fed765.(none)> 1748044166 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
2
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369 88d2b85cd4a760ba5f48260c9a1799a441f96369 root <root@a26af7fed765.(none)> 1748044166 +0000 checkout: moving from master to master
3
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369 7d85e318ab1eda4e409329d726facc84bbaa57c2 root <root@a26af7fed765.(none)> 1748044166 +0000 merge origin/development: Fast-forward
@@ -1,2 +1,2 @@
1
- 0000000000000000000000000000000000000000 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 root <root@8a49ade2be7e.(none)> 1747236124 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
2
- 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 208194810b58fc7e050508e7df5360b4f39d5b68 root <root@8a49ade2be7e.(none)> 1747236124 +0000 merge origin/development: Fast-forward
1
+ 0000000000000000000000000000000000000000 88d2b85cd4a760ba5f48260c9a1799a441f96369 root <root@a26af7fed765.(none)> 1748044166 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
2
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369 7d85e318ab1eda4e409329d726facc84bbaa57c2 root <root@a26af7fed765.(none)> 1748044166 +0000 merge origin/development: Fast-forward
@@ -1 +1 @@
1
- 0000000000000000000000000000000000000000 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 root <root@8a49ade2be7e.(none)> 1747236124 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
1
+ 0000000000000000000000000000000000000000 88d2b85cd4a760ba5f48260c9a1799a441f96369 root <root@a26af7fed765.(none)> 1748044166 +0000 clone: from github.com:strongdm/strongdm-sdk-ruby.git
data/.git/packed-refs CHANGED
@@ -1,6 +1,6 @@
1
1
  # pack-refs with: peeled fully-peeled sorted
2
- 208194810b58fc7e050508e7df5360b4f39d5b68 refs/remotes/origin/development
3
- 6a06ac49ca3c4d8d829450631d5f809c0fd5f593 refs/remotes/origin/master
2
+ 7d85e318ab1eda4e409329d726facc84bbaa57c2 refs/remotes/origin/development
3
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369 refs/remotes/origin/master
4
4
  2e4fe8087177ddea9b3991ca499f758384839c89 refs/tags/untagged-84fd83a4484c785cce63
5
5
  04f604866214fab4d5663b5171a3e596331577bd refs/tags/v0.9.4
6
6
  6f9a7b75b345c65fb554884907b7060680c807b7 refs/tags/v0.9.5
@@ -85,6 +85,8 @@ d92875bdf2278c475f52984d1165544d287e2255 refs/tags/v14.10.0
85
85
  856633eda480e15e9e53f3c76d373c9832734869 refs/tags/v14.11.0
86
86
  39946f5be0cf4bd4a6f3432cbe1caa0889a9fcf2 refs/tags/v14.12.0
87
87
  6a06ac49ca3c4d8d829450631d5f809c0fd5f593 refs/tags/v14.13.0
88
+ 208194810b58fc7e050508e7df5360b4f39d5b68 refs/tags/v14.14.0
89
+ 88d2b85cd4a760ba5f48260c9a1799a441f96369 refs/tags/v14.17.0
88
90
  f9539f7781664eb4681b99f12cbcc5d613e241ab refs/tags/v14.2.0
89
91
  435ad5faee6a7b0f94295b5d5fe9060611a81df3 refs/tags/v14.3.0
90
92
  90b476259dcfed955ebd9339fbe2bbb0c2086b6d refs/tags/v14.4.0
@@ -1 +1 @@
1
- 208194810b58fc7e050508e7df5360b4f39d5b68
1
+ 7d85e318ab1eda4e409329d726facc84bbaa57c2
@@ -1215,6 +1215,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
1215
1215
  optional :subdomain, :string, 32775
1216
1216
  optional :allow_resource_role_bypass, :bool, 15
1217
1217
  optional :certificate_authority, :string, 4
1218
+ optional :discovery_enabled, :bool, 13
1219
+ optional :discovery_username, :string, 14
1218
1220
  optional :healthcheck_namespace, :string, 6
1219
1221
  optional :identity_alias_healthcheck_username, :string, 8
1220
1222
  optional :identity_set_id, :string, 7
@@ -2017,6 +2019,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
2017
2019
  optional :password, :string, 2
2018
2020
  optional :port, :int32, 5
2019
2021
  optional :port_override, :int32, 4
2022
+ optional :tls_required, :bool, 7
2020
2023
  optional :username, :string, 6
2021
2024
  end
2022
2025
  add_message "v1.Vertica" do
@@ -68,6 +68,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
68
68
  optional :device_trust_enabled, :bool, 27
69
69
  optional :device_trust_provider, :string, 28
70
70
  optional :enforce_single_session, :bool, 29
71
+ optional :discard_replays, :bool, 30
72
+ optional :public_key_pem, :string, 31
71
73
  end
72
74
  end
73
75
  end
data/lib/grpc/plumbing.rb CHANGED
@@ -7693,6 +7693,8 @@ module SDM
7693
7693
  porcelain.allow_resource_role_bypass = (plumbing.allow_resource_role_bypass)
7694
7694
  porcelain.bind_interface = (plumbing.bind_interface)
7695
7695
  porcelain.certificate_authority = (plumbing.certificate_authority)
7696
+ porcelain.discovery_enabled = (plumbing.discovery_enabled)
7697
+ porcelain.discovery_username = (plumbing.discovery_username)
7696
7698
  porcelain.egress_filter = (plumbing.egress_filter)
7697
7699
  porcelain.healthcheck_namespace = (plumbing.healthcheck_namespace)
7698
7700
  porcelain.healthy = (plumbing.healthy)
@@ -7716,6 +7718,8 @@ module SDM
7716
7718
  plumbing.allow_resource_role_bypass = (porcelain.allow_resource_role_bypass)
7717
7719
  plumbing.bind_interface = (porcelain.bind_interface)
7718
7720
  plumbing.certificate_authority = (porcelain.certificate_authority)
7721
+ plumbing.discovery_enabled = (porcelain.discovery_enabled)
7722
+ plumbing.discovery_username = (porcelain.discovery_username)
7719
7723
  plumbing.egress_filter = (porcelain.egress_filter)
7720
7724
  plumbing.healthcheck_namespace = (porcelain.healthcheck_namespace)
7721
7725
  plumbing.healthy = (porcelain.healthy)
@@ -10049,6 +10053,7 @@ module SDM
10049
10053
  porcelain.created_at = convert_timestamp_to_porcelain(plumbing.created_at)
10050
10054
  porcelain.device_trust_enabled = (plumbing.device_trust_enabled)
10051
10055
  porcelain.device_trust_provider = (plumbing.device_trust_provider)
10056
+ porcelain.discard_replays = (plumbing.discard_replays)
10052
10057
  porcelain.enforce_single_session = (plumbing.enforce_single_session)
10053
10058
  porcelain.idle_timeout = convert_duration_to_porcelain(plumbing.idle_timeout)
10054
10059
  porcelain.idle_timeout_enabled = (plumbing.idle_timeout_enabled)
@@ -10063,6 +10068,7 @@ module SDM
10063
10068
  porcelain.mfa_enabled = (plumbing.mfa_enabled)
10064
10069
  porcelain.mfa_provider = (plumbing.mfa_provider)
10065
10070
  porcelain.name = (plumbing.name)
10071
+ porcelain.public_key_pem = (plumbing.public_key_pem)
10066
10072
  porcelain.require_secret_store = (plumbing.require_secret_store)
10067
10073
  porcelain.saml_metadata_url = (plumbing.saml_metadata_url)
10068
10074
  porcelain.scim_provider = (plumbing.scim_provider)
@@ -10085,6 +10091,7 @@ module SDM
10085
10091
  plumbing.created_at = convert_timestamp_to_plumbing(porcelain.created_at)
10086
10092
  plumbing.device_trust_enabled = (porcelain.device_trust_enabled)
10087
10093
  plumbing.device_trust_provider = (porcelain.device_trust_provider)
10094
+ plumbing.discard_replays = (porcelain.discard_replays)
10088
10095
  plumbing.enforce_single_session = (porcelain.enforce_single_session)
10089
10096
  plumbing.idle_timeout = convert_duration_to_plumbing(porcelain.idle_timeout)
10090
10097
  plumbing.idle_timeout_enabled = (porcelain.idle_timeout_enabled)
@@ -10099,6 +10106,7 @@ module SDM
10099
10106
  plumbing.mfa_enabled = (porcelain.mfa_enabled)
10100
10107
  plumbing.mfa_provider = (porcelain.mfa_provider)
10101
10108
  plumbing.name = (porcelain.name)
10109
+ plumbing.public_key_pem = (porcelain.public_key_pem)
10102
10110
  plumbing.require_secret_store = (porcelain.require_secret_store)
10103
10111
  plumbing.saml_metadata_url = (porcelain.saml_metadata_url)
10104
10112
  plumbing.scim_provider = (porcelain.scim_provider)
@@ -11365,6 +11373,7 @@ module SDM
11365
11373
  porcelain.encrypted = (plumbing.encrypted)
11366
11374
  porcelain.id = (plumbing.id)
11367
11375
  porcelain.identity_alias_username = (plumbing.identity_alias_username)
11376
+ porcelain.metadata_json = (plumbing.metadata_json)
11368
11377
  porcelain.query_body = (plumbing.query_body)
11369
11378
  porcelain.query_category = (plumbing.query_category)
11370
11379
  porcelain.query_hash = (plumbing.query_hash)
@@ -11401,6 +11410,7 @@ module SDM
11401
11410
  plumbing.encrypted = (porcelain.encrypted)
11402
11411
  plumbing.id = (porcelain.id)
11403
11412
  plumbing.identity_alias_username = (porcelain.identity_alias_username)
11413
+ plumbing.metadata_json = (porcelain.metadata_json)
11404
11414
  plumbing.query_body = (porcelain.query_body)
11405
11415
  plumbing.query_category = (porcelain.query_category)
11406
11416
  plumbing.query_hash = (porcelain.query_hash)
@@ -15925,6 +15935,7 @@ module SDM
15925
15935
  porcelain.secret_store_id = (plumbing.secret_store_id)
15926
15936
  porcelain.subdomain = (plumbing.subdomain)
15927
15937
  porcelain.tags = convert_tags_to_porcelain(plumbing.tags)
15938
+ porcelain.tls_required = (plumbing.tls_required)
15928
15939
  porcelain.username = (plumbing.username)
15929
15940
  porcelain
15930
15941
  end
@@ -15947,6 +15958,7 @@ module SDM
15947
15958
  plumbing.secret_store_id = (porcelain.secret_store_id)
15948
15959
  plumbing.subdomain = (porcelain.subdomain)
15949
15960
  plumbing.tags = convert_tags_to_plumbing(porcelain.tags)
15961
+ plumbing.tls_required = (porcelain.tls_required)
15950
15962
  plumbing.username = (porcelain.username)
15951
15963
  plumbing
15952
15964
  end
@@ -65,6 +65,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
65
65
  optional :authzJson, :string, 28
66
66
  optional :client_ip, :string, 29
67
67
  optional :identity_alias_username, :string, 30
68
+ optional :metadata_json, :string, 31
68
69
  end
69
70
  add_message "v1.QueryCapture" do
70
71
  optional :width, :int32, 1
@@ -7696,6 +7696,11 @@ module SDM
7696
7696
  attr_accessor :bind_interface
7697
7697
  # The CA to authenticate TLS connections with.
7698
7698
  attr_accessor :certificate_authority
7699
+ # If true, configures discovery of a cluster to be run from a node.
7700
+ attr_accessor :discovery_enabled
7701
+ # If a cluster is configured for user impersonation, this is the user to impersonate when
7702
+ # running discovery.
7703
+ attr_accessor :discovery_username
7699
7704
  # A filter applied to the routing logic to pin datasource to nodes.
7700
7705
  attr_accessor :egress_filter
7701
7706
  # The path used to check the health of your connection. Defaults to `default`.
@@ -7725,6 +7730,8 @@ module SDM
7725
7730
  allow_resource_role_bypass: nil,
7726
7731
  bind_interface: nil,
7727
7732
  certificate_authority: nil,
7733
+ discovery_enabled: nil,
7734
+ discovery_username: nil,
7728
7735
  egress_filter: nil,
7729
7736
  healthcheck_namespace: nil,
7730
7737
  healthy: nil,
@@ -7741,6 +7748,8 @@ module SDM
7741
7748
  @allow_resource_role_bypass = allow_resource_role_bypass == nil ? false : allow_resource_role_bypass
7742
7749
  @bind_interface = bind_interface == nil ? "" : bind_interface
7743
7750
  @certificate_authority = certificate_authority == nil ? "" : certificate_authority
7751
+ @discovery_enabled = discovery_enabled == nil ? false : discovery_enabled
7752
+ @discovery_username = discovery_username == nil ? "" : discovery_username
7744
7753
  @egress_filter = egress_filter == nil ? "" : egress_filter
7745
7754
  @healthcheck_namespace = healthcheck_namespace == nil ? "" : healthcheck_namespace
7746
7755
  @healthy = healthy == nil ? false : healthy
@@ -10011,6 +10020,8 @@ module SDM
10011
10020
  attr_accessor :device_trust_enabled
10012
10021
  # The Organization's device trust provider, one of the DeviceTrustProvider constants.
10013
10022
  attr_accessor :device_trust_provider
10023
+ # Indicates if the Organization should drop replay data for SSH, RDP, and K8s logs.
10024
+ attr_accessor :discard_replays
10014
10025
  # Indicates if the Organization enforces a single session per user for the CLI and AdminUI.
10015
10026
  attr_accessor :enforce_single_session
10016
10027
  # The Organization's idle timeout, if enabled.
@@ -10039,6 +10050,8 @@ module SDM
10039
10050
  attr_accessor :mfa_provider
10040
10051
  # The Organization's name.
10041
10052
  attr_accessor :name
10053
+ # The Organization's public key PEM for encrypting remote logs.
10054
+ attr_accessor :public_key_pem
10042
10055
  # Indicates if the Organization requires secret stores.
10043
10056
  attr_accessor :require_secret_store
10044
10057
  # The Organization's URL for SAML metadata.
@@ -10065,6 +10078,7 @@ module SDM
10065
10078
  created_at: nil,
10066
10079
  device_trust_enabled: nil,
10067
10080
  device_trust_provider: nil,
10081
+ discard_replays: nil,
10068
10082
  enforce_single_session: nil,
10069
10083
  idle_timeout: nil,
10070
10084
  idle_timeout_enabled: nil,
@@ -10079,6 +10093,7 @@ module SDM
10079
10093
  mfa_enabled: nil,
10080
10094
  mfa_provider: nil,
10081
10095
  name: nil,
10096
+ public_key_pem: nil,
10082
10097
  require_secret_store: nil,
10083
10098
  saml_metadata_url: nil,
10084
10099
  scim_provider: nil,
@@ -10094,6 +10109,7 @@ module SDM
10094
10109
  @created_at = created_at == nil ? nil : created_at
10095
10110
  @device_trust_enabled = device_trust_enabled == nil ? false : device_trust_enabled
10096
10111
  @device_trust_provider = device_trust_provider == nil ? "" : device_trust_provider
10112
+ @discard_replays = discard_replays == nil ? false : discard_replays
10097
10113
  @enforce_single_session = enforce_single_session == nil ? false : enforce_single_session
10098
10114
  @idle_timeout = idle_timeout == nil ? nil : idle_timeout
10099
10115
  @idle_timeout_enabled = idle_timeout_enabled == nil ? false : idle_timeout_enabled
@@ -10108,6 +10124,7 @@ module SDM
10108
10124
  @mfa_enabled = mfa_enabled == nil ? false : mfa_enabled
10109
10125
  @mfa_provider = mfa_provider == nil ? "" : mfa_provider
10110
10126
  @name = name == nil ? "" : name
10127
+ @public_key_pem = public_key_pem == nil ? "" : public_key_pem
10111
10128
  @require_secret_store = require_secret_store == nil ? false : require_secret_store
10112
10129
  @saml_metadata_url = saml_metadata_url == nil ? "" : saml_metadata_url
10113
10130
  @scim_provider = scim_provider == nil ? "" : scim_provider
@@ -11141,6 +11158,8 @@ module SDM
11141
11158
  attr_accessor :id
11142
11159
  # The username of the IdentityAlias used to access the Resource.
11143
11160
  attr_accessor :identity_alias_username
11161
+ # Driver specific metadata associated with this query.
11162
+ attr_accessor :metadata_json
11144
11163
  # The captured content of the Query.
11145
11164
  # For queries against SSH, Kubernetes, and RDP resources, this contains a JSON representation of the QueryCapture.
11146
11165
  attr_accessor :query_body
@@ -11191,6 +11210,7 @@ module SDM
11191
11210
  encrypted: nil,
11192
11211
  id: nil,
11193
11212
  identity_alias_username: nil,
11213
+ metadata_json: nil,
11194
11214
  query_body: nil,
11195
11215
  query_category: nil,
11196
11216
  query_hash: nil,
@@ -11220,6 +11240,7 @@ module SDM
11220
11240
  @encrypted = encrypted == nil ? false : encrypted
11221
11241
  @id = id == nil ? "" : id
11222
11242
  @identity_alias_username = identity_alias_username == nil ? "" : identity_alias_username
11243
+ @metadata_json = metadata_json == nil ? "" : metadata_json
11223
11244
  @query_body = query_body == nil ? "" : query_body
11224
11245
  @query_category = query_category == nil ? "" : query_category
11225
11246
  @query_hash = query_hash == nil ? "" : query_hash
@@ -14743,6 +14764,8 @@ module SDM
14743
14764
  attr_accessor :subdomain
14744
14765
  # Tags is a map of key, value pairs.
14745
14766
  attr_accessor :tags
14767
+ # If set, TLS must be used to connect to this resource.
14768
+ attr_accessor :tls_required
14746
14769
  # The username to authenticate with.
14747
14770
  attr_accessor :username
14748
14771
 
@@ -14760,6 +14783,7 @@ module SDM
14760
14783
  secret_store_id: nil,
14761
14784
  subdomain: nil,
14762
14785
  tags: nil,
14786
+ tls_required: nil,
14763
14787
  username: nil
14764
14788
  )
14765
14789
  @bind_interface = bind_interface == nil ? "" : bind_interface
@@ -14775,6 +14799,7 @@ module SDM
14775
14799
  @secret_store_id = secret_store_id == nil ? "" : secret_store_id
14776
14800
  @subdomain = subdomain == nil ? "" : subdomain
14777
14801
  @tags = tags == nil ? SDM::_porcelain_zero_value_tags() : tags
14802
+ @tls_required = tls_required == nil ? false : tls_required
14778
14803
  @username = username == nil ? "" : username
14779
14804
  end
14780
14805
 
data/lib/strongdm.rb CHANGED
@@ -25,25 +25,27 @@ module SDM #:nodoc:
25
25
 
26
26
  # Client bundles all the services together and initializes them.
27
27
  class Client
28
- DEFAULT_MAX_RETRIES = 3
29
- DEFAULT_BASE_RETRY_DELAY = 0.0030 # 30 ms
30
- DEFAULT_MAX_RETRY_DELAY = 300 # 300 seconds
28
+ DEFAULT_BASE_RETRY_DELAY = 1 # 1 second
29
+ DEFAULT_MAX_RETRY_DELAY = 120 # 120 seconds
30
+ DEFAULT_RETRY_FACTOR = 1.6
31
+ DEFAULT_RETRY_JITTER = 0.2
31
32
  API_VERSION = "2025-04-14"
32
- USER_AGENT = "strongdm-sdk-ruby/14.14.0"
33
- private_constant :DEFAULT_MAX_RETRIES, :DEFAULT_BASE_RETRY_DELAY, :DEFAULT_MAX_RETRY_DELAY, :API_VERSION, :USER_AGENT
33
+ USER_AGENT = "strongdm-sdk-ruby/14.20.0"
34
+ private_constant :DEFAULT_BASE_RETRY_DELAY, :DEFAULT_MAX_RETRY_DELAY, :DEFAULT_RETRY_FACTOR, :DEFAULT_RETRY_JITTER, :API_VERSION, :USER_AGENT
34
35
 
35
36
  # Creates a new strongDM API client.
36
- def initialize(api_access_key, api_secret_key, host: "app.strongdm.com:443", insecure: false, retry_rate_limit_errors: true, page_limit: 50)
37
+ def initialize(api_access_key, api_secret_key, host: "app.strongdm.com:443", insecure: false, retry_rate_limit_errors: true, page_limit: 0)
37
38
  raise TypeError, "client access key must be a string" unless api_access_key.kind_of?(String)
38
39
  raise TypeError, "client secret key must be a string" unless api_secret_key.kind_of?(String)
39
40
  raise TypeError, "client host must be a string" unless host.kind_of?(String)
40
41
  @api_access_key = api_access_key.strip
41
42
  @api_secret_key = Base64.strict_decode64(api_secret_key.strip)
42
- @max_retries = DEFAULT_MAX_RETRIES
43
43
  @base_retry_delay = DEFAULT_BASE_RETRY_DELAY
44
44
  @max_retry_delay = DEFAULT_MAX_RETRY_DELAY
45
+ @retry_factor = DEFAULT_RETRY_FACTOR
46
+ @retry_jitter = DEFAULT_RETRY_JITTER
45
47
  @page_limit = page_limit
46
- @expose_rate_limit_errors = (not retry_rate_limit_errors)
48
+ @retry_rate_limit_errors = retry_rate_limit_errors
47
49
  @snapshot_time = nil
48
50
  begin
49
51
  if insecure
@@ -153,18 +155,44 @@ module SDM #:nodoc:
153
155
  end
154
156
 
155
157
  # @private
156
- def jitterSleep(iter)
157
- dur_max = @base_retry_delay * 2 ** iter
158
- if (dur_max > @max_retry_delay)
159
- dur_max = @max_retry_delay
158
+ def exponentialBackoff(retries, deadline = nil)
159
+ if retries == 0
160
+ return applyDeadline(@base_retry_delay, deadline)
160
161
  end
161
- dur = rand() * dur_max
162
- sleep(dur)
162
+ backoff, max = @base_retry_delay, @max_retry_delay
163
+ while backoff < max and retries > 0
164
+ backoff *= @retry_factor
165
+ retries -= 1
166
+ end
167
+ if backoff > max
168
+ backoff = max
169
+ end
170
+ # Randomize backoff delays so that if a cluster of requests start at
171
+ # the same time, they won't operate in lockstep.
172
+ backoff *= 1 + @retry_jitter * (rand() * 2 - 1)
173
+ if backoff < 0
174
+ return 0
175
+ end
176
+
177
+ return applyDeadline(backoff, deadline)
178
+ end
179
+
180
+ # @private
181
+ def applyDeadline(backoff, deadline)
182
+ if deadline.nil?
183
+ return backoff
184
+ end
185
+ remaining = deadline - Time.now
186
+ if remaining < 0
187
+ return 0
188
+ end
189
+ return [backoff, remaining].min
163
190
  end
164
191
 
165
192
  # @private
166
- def shouldRetry(iter, err)
167
- if (iter >= @max_retries - 1)
193
+ def shouldRetry(retries, err, deadline = nil)
194
+ # Check if we've passed the deadline
195
+ if !deadline.nil? && Time.now >= deadline
168
196
  return false
169
197
  end
170
198
  # The grpc library unfortunately does not raise a more specific error class.
@@ -172,20 +200,12 @@ module SDM #:nodoc:
172
200
  return false
173
201
  end
174
202
  if not err.is_a? GRPC::BadStatus
175
- return true
203
+ return false
176
204
  end
177
- porcelainErr = Plumbing::convert_error_to_porcelain(err)
178
- if (not @expose_rate_limit_errors) and (porcelainErr.is_a? RateLimitError)
179
- sleep_for = porcelainErr.rate_limit.reset_at - Time.now
180
- # If timezones or clock drift causes this calculation to fail,
181
- # wait at most one minute.
182
- if sleep_for < 0 or sleep_for > 60
183
- sleep_for = 60
184
- end
185
- sleep(sleep_for)
205
+ if @retry_rate_limit_errors and err.code() == 8
186
206
  return true
187
207
  end
188
- return (err.code() == 13 or err.code() == 14)
208
+ return (retries <= 3) && ((err.code() == 13) || (err.code() == 14))
189
209
  end
190
210
 
191
211
  # Constructs a read-only client that will provide historical data from the provided timestamp.
@@ -196,7 +216,11 @@ module SDM #:nodoc:
196
216
  return SnapshotClient.new(client)
197
217
  end
198
218
 
199
- attr_reader :max_retries
219
+ # @deprecated
220
+ def max_retries
221
+ 3
222
+ end
223
+
200
224
  attr_reader :base_retry_delay
201
225
  attr_reader :max_retry_delay
202
226
  attr_accessor :page_limit