Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ runs:

- name: Run contract tests v3
if: ${{ inputs.flaky != 'true' }}
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests/v1
with:
test_service_port: 9000
enable_persistence_tests: true
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages/v1
name: 'Publish to Github pages'
with:
docs_path: docs/build/html/
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
runs:
using: composite
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: 'gems-*'
merge-multiple: true
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ runs:
distribution: temurin
java-version: "21"

- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
- uses: ruby/setup-ruby@b3aaceaef7e0ee231b499e7b5f49c03fc1d32199 # v1.338.0
with:
ruby-version: ${{ inputs.version }}
bundler: "4.0.19"
Expand Down
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directories:
- '/'
- '/.github/actions/*'
schedule:
interval: 'monthly'
cooldown:
default-days: 7
exclude:
- 'launchdarkly/*'
4 changes: 0 additions & 4 deletions .github/renovate.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: launchdarkly/gh-actions/actions/persistent-stores@persistent-stores-v0
- uses: launchdarkly/gh-actions/actions/persistent-stores@persistent-stores/v0
with:
redis: true
consul: true
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Build gemspec
run: gem build launchdarkly-server-sdk.gemspec --platform=$BUILD_PLATFORM

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ inputs.upload-artifact }}
with:
name: gems-${{ inputs.version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
version: "3.4"
install-dependencies: false

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets/v1
name: "Get rubygems API key"
if: ${{ format('{0}', inputs.dry_run) == 'false' }}
with:
Expand All @@ -56,6 +56,6 @@ jobs:

- name: Attest build provenance
if: ${{ format('{0}', inputs.dry_run) == 'false' }}
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: 'launchdarkly-server-sdk-*.gem'
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
version: "3.4"
install-dependencies: false

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets/v1
name: "Get rubygems API key"
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
Expand All @@ -70,6 +70,6 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Attest build provenance
uses: actions/attest@f7c74d28b9d84cb8768d0b8ca14a4bac6ef463e6 # v4.2.0
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: 'launchdarkly-server-sdk-*.gem'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LaunchDarkly overview
Supported Ruby versions
-----------------------

This version of the LaunchDarkly SDK has a minimum Ruby version of 3.4.0. On JRuby, the minimum is JRuby 10.0, which requires Java 21.
While this version of the LaunchDarkly SDK requires Ruby 3.4.0 or later (or JRuby 10.0 or later, which requires Java 21), you should use the latest patched version of a supported Ruby or JRuby release.

Getting started
-----------
Expand Down
15 changes: 15 additions & 0 deletions contract-tests/client_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def initialize(log, config)

opts[:logger] = log

# A per-component baseUri set below takes precedence over these.
service_endpoints = config[:serviceEndpoints]
if service_endpoints
opts[:stream_uri] = service_endpoints[:streaming] if service_endpoints[:streaming]
opts[:base_uri] = service_endpoints[:polling] if service_endpoints[:polling]
opts[:events_uri] = service_endpoints[:events] if service_endpoints[:events]
end

data_system_config = config[:dataSystem]
if data_system_config
data_system = LaunchDarkly::DataSystem.custom
Expand Down Expand Up @@ -91,6 +99,13 @@ def initialize(log, config)
}
end

if config[:wrapper]
# The harness sends an empty string for an unset name or version.
wrapper = config[:wrapper]
opts[:wrapper_name] = wrapper[:name] unless wrapper[:name].to_s.empty?
opts[:wrapper_version] = wrapper[:version] unless wrapper[:version].to_s.empty?
end

if config[:hooks]
opts[:hooks] = config[:hooks][:hooks].map do |hook|
Hook.new(hook[:name], hook[:callbackUri], hook[:data] || {}, hook[:errors] || {})
Expand Down
4 changes: 4 additions & 0 deletions contract-tests/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'migrations',
'event-gzip',
'optional-event-gzip',
'diagnostic-events',
'event-sampling',
'context-comparison',
'polling-gzip',
Expand All @@ -53,6 +54,9 @@
'flag-change-listeners',
'flag-value-change-listeners',
'fdv1-fallback',
'wrapper',
'service-endpoints',
'tls:verify-peer',
],
}.to_json
end
Expand Down
18 changes: 15 additions & 3 deletions spec/ldclient_listeners_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module LaunchDarkly
end

it "sends status updates" do
store = MockBigSegmentStore.new
store.setup_metadata(Time.now)
store = GatedBigSegmentStore.new
store.queue_metadata(Time.now)
big_segments_config = BigSegmentsConfig.new(
store: store,
status_poll_interval: 0.01
Expand All @@ -24,17 +24,29 @@ module LaunchDarkly
expect(status1.available).to be(true)
expect(status1.stale).to be(false)

# Status reads after the first come from the cache, so the second query comes from the
# poller. Observers have been notified of the first status by the time it starts, so the
# observer added below sees only later changes.
expect(store.wait_for_queries(2)).to be(true)

statuses = Queue.new
observer = SimpleObserver.adding_to_queue(statuses)
client.big_segment_store_status_provider.add_observer(observer)

store.setup_metadata_error(StandardError.new("sorry"))
# Fail the waiting query, then wait for the poller to start the next one. It has notified
# observers of the failure by then.
store.queue_metadata_error(StandardError.new("sorry"))
expect(store.wait_for_queries(3)).to be(true)

# The observer should have received one status, reporting the store as unavailable.
expect(statuses.size).to eq(1)
status2 = statuses.pop
expect(status2.available).to be(false)
expect(status2.stale).to be(false)

expect(client.big_segment_store_status_provider.status).to eq(status2)
ensure
store.release
end
end
end
Expand Down
81 changes: 81 additions & 0 deletions spec/mock_components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,87 @@ def setup_segment_for_context(user_key, segment, included)
end
end

#
# A Big Segment store whose metadata queries wait for the test to supply each result.
#
# The status poller notifies observers of one result before it starts its next query. Once a
# test sees a query start, every earlier result has been delivered, and the poller stays in that
# query until the test supplies another result.
#
# Call {#release} before closing the client. The poller cannot stop while a query is waiting.
#
class GatedBigSegmentStore
def initialize
@lock = Mutex.new
@changed = ConditionVariable.new
@results = []
@last_result = nil
@queries_started = 0
@released = false
end

def get_metadata
result = @lock.synchronize do
@queries_started += 1
@changed.broadcast
@changed.wait(@lock) while @results.empty? && !@released
@last_result = @results.shift unless @results.empty?
@last_result
end
raise result if result.is_a?(Exception)
result
end

def get_membership(_context_hash)
nil
end

def stop
end

# Supplies the result of the next metadata query.
def queue_metadata(last_up_to_date)
queue_result(Interfaces::BigSegmentStoreMetadata.new(last_up_to_date.to_f * 1000))
end

# Makes the next metadata query raise the given error.
def queue_metadata_error(ex)
queue_result(ex)
end

#
# Blocks until the store has received `count` metadata queries, or until the timeout passes.
#
# @return [Boolean] false if the queries did not start within the timeout
#
def wait_for_queries(count, timeout: 5)
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout
@lock.synchronize do
while @queries_started < count
remaining = deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC)
return false if remaining <= 0
@changed.wait(@lock, remaining)
end
true
end
end

# Stops queries from waiting. Waiting and later queries return the last result again.
def release
@lock.synchronize do
@released = true
@changed.broadcast
end
end

private def queue_result(result)
@lock.synchronize do
@results << result
@changed.broadcast
end
end
end

class SimpleObserver
def initialize(fn)
@fn = fn
Expand Down