Add Rust domain kernel and wire contracts
This commit is contained in:
parent
ff379fb002
commit
4da5a980ed
1 changed files with 3757 additions and 1 deletions
169
crates/remora-contracts/src/internal.rs
Normal file
169
crates/remora-contracts/src/internal.rs
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
use remora_domain::OpaqueId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
AttemptAuthorityDto, CredentialGrantVersionDto, DurableDescriptorKindDto,
|
||||
DurableDescriptorRefDto, LeaseProjectionDto, NullableDto, PositiveIntegerDto, ProgressValueDto,
|
||||
SafeIntegerDto, SourceProjectionDto, StagingTargetDto, TargetDto,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ClaimRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ExecutionEnvelopeDto {
|
||||
pub id: OpaqueId,
|
||||
pub job_id: OpaqueId,
|
||||
pub attempt_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
pub source: SourceProjectionDto,
|
||||
pub sensitive_source_ref: OpaqueId,
|
||||
pub credential_version: NullableDto<CredentialGrantVersionDto>,
|
||||
pub resolved_source_ref: NullableDto<DurableDescriptorRefDto>,
|
||||
pub target: TargetDto,
|
||||
pub staging_target: StagingTargetDto,
|
||||
pub execution_grant_ref: OpaqueId,
|
||||
pub checkpoint_ref: NullableDto<DurableDescriptorRefDto>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ClaimResponseDto {
|
||||
pub authority: AttemptAuthorityDto,
|
||||
pub execution: ExecutionEnvelopeDto,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ActivationResponseDto {
|
||||
pub authority: AttemptAuthorityDto,
|
||||
pub execution: ExecutionEnvelopeDto,
|
||||
pub lease: LeaseProjectionDto,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptMutationDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptRenewRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptActivateRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ResolvedSourceDescriptorRefDto {
|
||||
pub id: OpaqueId,
|
||||
pub kind: ResolvedSourceDescriptorKindDto,
|
||||
pub schema_version: PositiveIntegerDto,
|
||||
pub byte_length: SafeIntegerDto,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "crate::dto::optional_non_null",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub item_count: Option<SafeIntegerDto>,
|
||||
pub checksum: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ResolvedSourceDescriptorKindDto {
|
||||
ResolvedSource,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct CheckpointDescriptorRefDto {
|
||||
pub id: OpaqueId,
|
||||
pub kind: CheckpointDescriptorKindDto,
|
||||
pub schema_version: PositiveIntegerDto,
|
||||
pub byte_length: SafeIntegerDto,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "crate::dto::optional_non_null",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub item_count: Option<SafeIntegerDto>,
|
||||
pub checksum: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CheckpointDescriptorKindDto {
|
||||
Checkpoint,
|
||||
}
|
||||
|
||||
impl From<ResolvedSourceDescriptorRefDto> for DurableDescriptorRefDto {
|
||||
fn from(value: ResolvedSourceDescriptorRefDto) -> Self {
|
||||
Self {
|
||||
id: value.id,
|
||||
kind: DurableDescriptorKindDto::ResolvedSource,
|
||||
schema_version: value.schema_version,
|
||||
byte_length: value.byte_length,
|
||||
item_count: value.item_count,
|
||||
checksum: value.checksum,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CheckpointDescriptorRefDto> for DurableDescriptorRefDto {
|
||||
fn from(value: CheckpointDescriptorRefDto) -> Self {
|
||||
Self {
|
||||
id: value.id,
|
||||
kind: DurableDescriptorKindDto::Checkpoint,
|
||||
schema_version: value.schema_version,
|
||||
byte_length: value.byte_length,
|
||||
item_count: value.item_count,
|
||||
checksum: value.checksum,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptResolvedSourceRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
pub resolved_source_ref: ResolvedSourceDescriptorRefDto,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptCheckpointRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
pub checkpoint_ref: CheckpointDescriptorRefDto,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AttemptProgressRequestDto {
|
||||
pub operation_id: OpaqueId,
|
||||
pub fence: PositiveIntegerDto,
|
||||
pub worker_incarnation: OpaqueId,
|
||||
pub progress: ProgressValueDto,
|
||||
}
|
||||
Loading…
Reference in a new issue