Skip to main content

Priority

Struct Priority 

Source
pub struct Priority {
    pub priority_key: i32,
    pub fairness_key: String,
    pub fairness_weight: f32,
}
Expand description

Priority contains metadata that controls relative ordering of task processing when tasks are backed up in a queue. Initially, Priority will be used in matching (workflow and activity) task queues. Later it may be used in history task queues and in rate limiting decisions.

Priority is attached to workflows and activities. By default, activities inherit Priority from the workflow that created them, but may override fields when an activity is started or modified.

Despite being named “Priority”, this message also contains fields that control “fairness” mechanisms.

For all fields, the field not present or equal to zero/empty string means to inherit the value from the calling workflow, or if there is no calling workflow, then use the default value.

For all fields other than fairness_key, the zero value isn’t meaningful so there’s no confusion between inherit/default and a meaningful value. For fairness_key, the empty string will be interpreted as “inherit”. This means that if a workflow has a non-empty fairness key, you can’t override the fairness key of its activity to the empty string.

The overall semantics of Priority are:

  1. First, consider “priority”: higher priority (lower number) goes first.
  2. Then, consider fairness: try to dispatch tasks for different fairness keys in proportion to their weight.

Applications may use any subset of mechanisms that are useful to them and leave the other fields to use default values.

Not all queues in the system may support the “full” semantics of all priority fields. (Currently only support in matching task queues is planned.)

Fields§

§priority_key: i32

Priority key is a positive integer from 1 to n, where smaller integers correspond to higher priorities (tasks run sooner). In general, tasks in a queue should be processed in close to priority order, although small deviations are possible.

The maximum priority value (minimum priority) is determined by server configuration, and defaults to 5.

If priority is not present (or zero), then the effective priority will be the default priority, which is calculated by (min+max)/2. With the default max of 5, and min of 1, that comes out to 3.

§fairness_key: String

Fairness key is a short string that’s used as a key for a fairness balancing mechanism. It may correspond to a tenant id, or to a fixed string like “high” or “low”. The default is the empty string.

The fairness mechanism attempts to dispatch tasks for a given key in proportion to its weight. For example, using a thousand distinct tenant ids, each with a weight of 1.0 (the default) will result in each tenant getting a roughly equal share of task dispatch throughput.

(Note: this does not imply equal share of worker capacity! Fairness decisions are made based on queue statistics, not current worker load.)

As another example, using keys “high” and “low” with weight 9.0 and 1.0 respectively will prefer dispatching “high” tasks over “low” tasks at a 9:1 ratio, while allowing either key to use all worker capacity if the other is not present.

All fairness mechanisms, including rate limits, are best-effort and probabilistic. The results may not match what a “perfect” algorithm with infinite resources would produce. The more unique keys are used, the less accurate the results will be.

Fairness keys are limited to 64 bytes.

§fairness_weight: f32

Fairness weight for a task can come from multiple sources for flexibility. From highest to lowest precedence:

  1. Weights for a small set of keys can be overridden in task queue configuration with an API.
  2. It can be attached to the workflow/activity in this field.
  3. The default weight of 1.0 will be used.

Weight values are clamped to the range [0.001, 1000].

Trait Implementations§

Source§

impl Clone for Priority

Source§

fn clone(&self) -> Priority

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Priority

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Priority

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for Priority

§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Priority> for Priority

Source§

fn from(priority: Priority) -> Self

Converts to this type from the input type.
Source§

impl From<Priority> for Priority

Source§

fn from(priority: Priority) -> Self

Converts to this type from the input type.
Source§

impl Message for Priority

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl Name for Priority

Source§

const NAME: &'static str = "Priority"

Simple name for this Message. This name is the same as it appears in the source .proto file, e.g. FooBar.
Source§

const PACKAGE: &'static str = "temporal.api.common.v1"

Package name this message type is contained in. They are domain-like and delimited by ., e.g. google.protobuf.
Source§

fn full_name() -> String

Fully-qualified unique name for this Message. It’s prefixed with the package name and names of any parent messages, e.g. google.rpc.BadRequest.FieldViolation. By default, this is the package name followed by the message name. Fully-qualified names must be unique within a domain of Type URLs.
Source§

fn type_url() -> String

Type URL for this Message, which by default is the full name with a leading slash, but may also include a leading domain name, e.g. type.googleapis.com/google.profile.Person. This can be used when serializing into the google.protobuf.Any type.
Source§

impl PartialEq for Priority

Source§

fn eq(&self, other: &Priority) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for Priority

§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Priority

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsJsonPayloadExt for T
where T: Serialize,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromJsonPayloadExt for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> TemporalDeserializable for T

Source§

fn from_serde( pc: &dyn ErasedSerdePayloadConverter, context: &SerializationContext<'_>, payload: Payload, ) -> Result<T, PayloadConversionError>

Deserialize from a serde-based payload converter.
Source§

fn from_payload( ctx: &SerializationContext<'_>, payload: Payload, ) -> Result<Self, PayloadConversionError>

Deserialize from a single Payload.
Source§

fn from_payloads( ctx: &SerializationContext<'_>, payloads: Vec<Payload>, ) -> Result<Self, PayloadConversionError>

Convert from multiple payloads. Override this for types representing multiple arguments.
Source§

impl<T> TemporalSerializable for T
where T: Serialize,

Source§

fn as_serde(&self) -> Result<&dyn Serialize, PayloadConversionError>

Return a reference to this value as a serde-serializable trait object.
Source§

fn to_payload( &self, _: &SerializationContext<'_>, ) -> Result<Payload, PayloadConversionError>

Convert this value into a single Payload.
Source§

fn to_payloads( &self, ctx: &SerializationContext<'_>, ) -> Result<Vec<Payload>, PayloadConversionError>

Convert to multiple payloads. Override this for types representing multiple arguments.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,