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.



633
634
635
# File 'lib/temporalio/client/schedule.rb', line 633

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

Instance Attribute Details

#everyFloat

Returns Period to repeat the interval.

Returns:

  • (Float)

    Period to repeat the interval.



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/temporalio/client/schedule.rb', line 620

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.



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/temporalio/client/schedule.rb', line 620

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