Class: LaunchDarkly::Interfaces::DataSystem::FetchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/interfaces/data_system.rb

Overview

FetchResult pairs the result of an Initializer#fetch call with the server-directed FDv1 Fallback Directive signal.

When the LaunchDarkly server returns the ‘X-LD-FD-Fallback: true` response header on an initializer response, the SDK must apply any accompanying payload and then switch to the FDv1 Fallback Synchronizer. Surfacing this signal alongside the Result ensures callers cannot silently drop it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result:, fallback_to_fdv1: false) ⇒ FetchResult

Returns a new instance of FetchResult.

Parameters:

  • result (LaunchDarkly::Result)

    A Result containing either a Basis or an error.

  • fallback_to_fdv1 (Boolean) (defaults to: false)

    Whether to fall back to FDv1.



567
568
569
570
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 567

def initialize(result:, fallback_to_fdv1: false)
  @result = result
  @fallback_to_fdv1 = fallback_to_fdv1
end

Instance Attribute Details

#fallback_to_fdv1Boolean (readonly)

Returns Whether the server has instructed the SDK to fall back to the FDv1 protocol.

Returns:

  • (Boolean)

    Whether the server has instructed the SDK to fall back to the FDv1 protocol.



561
562
563
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 561

def fallback_to_fdv1
  @fallback_to_fdv1
end

#resultLaunchDarkly::Result (readonly)

Returns A Result containing either a Basis or an error.

Returns:



558
559
560
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 558

def result
  @result
end

Instance Method Details

#errorString?

Returns An error description, or nil on success.

Returns:

  • (String, nil)

    An error description, or nil on success.



583
584
585
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 583

def error
  @result.error
end

#exceptionException?

Returns An optional exception describing the failure.

Returns:

  • (Exception, nil)

    An optional exception describing the failure.



588
589
590
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 588

def exception
  @result.exception
end

#success?Boolean

Returns true when the underlying Result was successful.

Returns:

  • (Boolean)

    true when the underlying Result was successful.



573
574
575
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 573

def success?
  @result.success?
end

#valueObject?

Returns The Basis returned from a successful fetch, or nil.

Returns:

  • (Object, nil)

    The Basis returned from a successful fetch, or nil.



578
579
580
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 578

def value
  @result.value
end