Class: Temporalio::Client::Schedule::Spec::Interval

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/client/schedule.rb

Overview

Specification for scheduling on an interval.

Matches times expressed as epoch + (n * every) + offset.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(every:, offset: nil) ⇒ Interval

Create an interval spec.

Parameters:

  • every (Float)

    Period to repeat the interval.

  • offset (Float, nil) (defaults to: nil)

    Fixed offset added to each interval period.



609
610
611
# File 'lib/temporalio/client/schedule.rb', line 609

def initialize(every:, offset: nil)
  super
end

Instance Attribute Details

#everyFloat

Returns Period to repeat the interval.

Returns:

  • (Float)

    Period to repeat the interval.



596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/temporalio/client/schedule.rb', line 596

class Interval
  # @!visibility private
  def self._from_proto(raw_int)
    Schedule::Spec::Interval.new(
      every: Internal::ProtoUtils.duration_to_seconds(raw_int.interval) || raise, # Never nil
      offset: Internal::ProtoUtils.duration_to_seconds(raw_int.phase)
    )
  end

  # Create an interval spec.
  #
  # @param every [Float] Period to repeat the interval.
  # @param offset [Float, nil] Fixed offset added to each interval period.
  def initialize(every:, offset: nil)
    super
  end

  # @!visibility private
  def _to_proto
    Api::Schedule::V1::IntervalSpec.new(
      interval: Internal::ProtoUtils.seconds_to_duration(every),
      phase: Internal::ProtoUtils.seconds_to_duration(offset)
    )
  end
end

#offsetFloat?

Returns Fixed offset added to each interval period.

Returns:

  • (Float, nil)

    Fixed offset added to each interval period.



596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/temporalio/client/schedule.rb', line 596

class Interval
  # @!visibility private
  def self._from_proto(raw_int)
    Schedule::Spec::Interval.new(
      every: Internal::ProtoUtils.duration_to_seconds(raw_int.interval) || raise, # Never nil
      offset: Internal::ProtoUtils.duration_to_seconds(raw_int.phase)
    )
  end

  # Create an interval spec.
  #
  # @param every [Float] Period to repeat the interval.
  # @param offset [Float, nil] Fixed offset added to each interval period.
  def initialize(every:, offset: nil)
    super
  end

  # @!visibility private
  def _to_proto
    Api::Schedule::V1::IntervalSpec.new(
      interval: Internal::ProtoUtils.seconds_to_duration(every),
      phase: Internal::ProtoUtils.seconds_to_duration(offset)
    )
  end
end