Skip to content

Commit

Permalink
Use Rust doc for documenting DF table schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Jun 17, 2024
1 parent 63c109c commit 1dd4580
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 88 deletions.
15 changes: 11 additions & 4 deletions crates/storage-query-datafusion/src/deployment/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(deployment(
id "The ID of the service deployment.": DataType::LargeUtf8,
ty "The type of the endpoint. Either `http` or `lambda`.": DataType::LargeUtf8,
endpoint "The address of the endpoint. Either HTTP URL or Lambda ARN.": DataType::LargeUtf8,
created_at "Timestamp indicating the deployment registration time.": DataType::Date64,
/// The ID of the service deployment.
id: DataType::LargeUtf8,

/// The type of the endpoint. Either `http` or `lambda`.
ty: DataType::LargeUtf8,

/// The address of the endpoint. Either HTTP URL or Lambda ARN.
endpoint: DataType::LargeUtf8,

/// Timestamp indicating the deployment registration time.
created_at: DataType::Date64,
));
21 changes: 15 additions & 6 deletions crates/storage-query-datafusion/src/idempotency/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(idempotency(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

service_name "The name for the invoked service.": DataType::LargeUtf8,
service_key "The key of the Virtual Object or of the Workflow. Null for regular services.": DataType::LargeUtf8,
service_handler "The invoked handler.": DataType::LargeUtf8,
idempotency_key "The user provided idempotency key.": DataType::LargeUtf8,
/// The name for the invoked service.
service_name: DataType::LargeUtf8,

invocation_id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8
/// The key of the Virtual Object or of the Workflow. Null for regular services.
service_key: DataType::LargeUtf8,

/// The invoked handler.
service_handler: DataType::LargeUtf8,

/// The user provided idempotency key.
idempotency_key: DataType::LargeUtf8,

/// [Invocation ID](/operate/invocation#invocation-identifier).
invocation_id: DataType::LargeUtf8
));
19 changes: 13 additions & 6 deletions crates/storage-query-datafusion/src/inbox/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(inbox(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

service_name "The name for the invoked virtual object/workflow.": DataType::LargeUtf8,
service_key "The key of the virtual object/workflow.": DataType::LargeUtf8,
/// The name for the invoked virtual object/workflow.
service_name: DataType::LargeUtf8,

id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8,
/// The key of the virtual object/workflow.
service_key: DataType::LargeUtf8,

sequence_number "Sequence number in the inbox.": DataType::UInt64,
/// [Invocation ID](/operate/invocation#invocation-identifier).
id: DataType::LargeUtf8,

created_at "Timestamp indicating the start of this invocation.": DataType::Date64,
/// Sequence number in the inbox.
sequence_number: DataType::UInt64,

/// Timestamp indicating the start of this invocation.
created_at: DataType::Date64,
));
55 changes: 41 additions & 14 deletions crates/storage-query-datafusion/src/invocation_state/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,50 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(state(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

in_flight "If true, the invocation is currently in-flight": DataType::Boolean,
retry_count "The number of attempts since the last successful attempt of this invocation. Increments on start, so 2 or more means a failure occurred.": DataType::UInt64,
last_start_at "Timestamp indicating the start of the most recent attempt of this invocation.": DataType::Date64,
/// [Invocation ID](/operate/invocation#invocation-identifier).
id: DataType::LargeUtf8,

/// If true, the invocation is currently in-flight
in_flight: DataType::Boolean,

/// The number of attempts since the last successful attempt of this invocation.
/// Increments on start, so 2 or more means a failure occurred.
retry_count: DataType::UInt64,

/// Timestamp indicating the start of the most recent attempt of this invocation.
last_start_at: DataType::Date64,

// The deployment that was selected in the last invocation attempt. This is
// guaranteed to be set unlike in `sys_status` table which require that the
// deployment to be committed before it is set.
last_attempt_deployment_id "The opaque service deployment ID that was used in the most recent attempt of this invocation; this will be set before a journal entry is stored, but can change later.": DataType::LargeUtf8,
last_attempt_server "Server/SDK version, e.g. `restate-sdk-java/1.0.1`": DataType::LargeUtf8,
next_retry_at "Timestamp indicating the start of the next attempt of this invocation.": DataType::Date64,

last_failure "An error message describing the most recent failed attempt of this invocation, if any.": DataType::LargeUtf8,
last_failure_error_code "The error code of the most recent failed attempt of this invocation, if any.": DataType::LargeUtf8,
last_failure_related_entry_index "The index of the journal entry that caused the failure, if any. It may be out-of-bound of the currently stored entries in `sys_journal`.": DataType::UInt64,
last_failure_related_entry_name "The name of the journal entry that caused the failure, if any.": DataType::LargeUtf8,
last_failure_related_entry_type "The type of the journal entry that caused the failure, if any. You can check all the available entry types in [`entries.rs`](https://github.com/restatedev/restate/blob/main/crates/types/src/journal/entries.rs).": DataType::LargeUtf8,

/// The opaque service deployment ID that was used in the most recent attempt of this
/// invocation; this will be set before a journal entry is stored, but can change later.
last_attempt_deployment_id: DataType::LargeUtf8,

/// Server/SDK version, e.g. `restate-sdk-java/1.0.1`
last_attempt_server: DataType::LargeUtf8,

/// Timestamp indicating the start of the next attempt of this invocation.
next_retry_at: DataType::Date64,

/// An error message describing the most recent failed attempt of this invocation, if any.
last_failure: DataType::LargeUtf8,

/// The error code of the most recent failed attempt of this invocation, if any.
last_failure_error_code: DataType::LargeUtf8,

/// The index of the journal entry that caused the failure, if any. It may be out-of-bound
/// of the currently stored entries in `sys_journal`.
last_failure_related_entry_index: DataType::UInt64,

/// The name of the journal entry that caused the failure, if any.
last_failure_related_entry_name: DataType::LargeUtf8,

/// The type of the journal entry that caused the failure, if any. You can check all the
/// available entry types in [`entries.rs`](https://github.com/restatedev/restate/blob/main/crates/types/src/journal/entries.rs).
last_failure_related_entry_type: DataType::LargeUtf8,
));
79 changes: 58 additions & 21 deletions crates/storage-query-datafusion/src/invocation_status/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,62 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(invocation_status(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8,

status "Either `inboxed` or `invoked` or `suspended` or `completed`": DataType::LargeUtf8,

target "Invocation Target. Format for plain services: `ServiceName/HandlerName`, e.g. `Greeter/greet`. Format for Virtual Objects/Workflows: `VirtualObjectName/Key/HandlerName`, e.g. `Greeter/Francesco/greet`.": DataType::LargeUtf8,
target_service_name "The name for the invoked service.": DataType::LargeUtf8,
target_service_key "The key of the Virtual Object or of the Workflow. Null for regular services.": DataType::LargeUtf8,
target_handler_name "The invoked handler.": DataType::LargeUtf8,
target_service_ty "The service type. Either `service` or `virtual_object` or `workflow`.": DataType::LargeUtf8,

invoked_by "Either `ingress` if the service was invoked externally or `service` if the service was invoked by another Restate service.": DataType::LargeUtf8,
invoked_by_service_name "The name of the invoking service. Or `null` if invoked externally.": DataType::LargeUtf8,
invoked_by_id "The caller [Invocation ID](/operate/invocation#invocation-identifier) if the service was invoked by another Restate service. Or `null` if invoked externally.": DataType::LargeUtf8,
invoked_by_target "The caller invocation target if the service was invoked by another Restate service. Or `null` if invoked externally.": DataType::LargeUtf8,

pinned_deployment_id "The opaque service deployment ID that has been committed for this invocation; this is set after the first journal entry is stored for this invocation.": DataType::LargeUtf8,
trace_id "The ID of the trace that is assigned to this invocation. Only relevant when tracing is enabled.": DataType::LargeUtf8,
journal_size "The number of journal entries durably logged for this invocation.": DataType::UInt32,
created_at "Timestamp indicating the start of this invocation.": DataType::Date64,
modified_at "Timestamp indicating the last state transition. For example, last time the status changed from `invoked` to `suspended`.": DataType::Date64,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

/// [Invocation ID](/operate/invocation#invocation-identifier).
id: DataType::LargeUtf8,

/// Either `inboxed` or `invoked` or `suspended` or `completed`
status: DataType::LargeUtf8,

/// Invocation Target. Format for plain services: `ServiceName/HandlerName`, e.g.
/// `Greeter/greet`. Format for Virtual Objects/Workflows: `VirtualObjectName/Key/HandlerName`,
/// e.g. `Greeter/Francesco/greet`.
target: DataType::LargeUtf8,

/// The name for the invoked service.
target_service_name: DataType::LargeUtf8,

/// The key of the Virtual Object or of the Workflow. Null for regular services.
target_service_key: DataType::LargeUtf8,

/// The invoked handler.
target_handler_name: DataType::LargeUtf8,

/// The service type. Either `service` or `virtual_object` or `workflow`.
target_service_ty: DataType::LargeUtf8,

/// Either `ingress` if the service was invoked externally or `service` if the service was
/// invoked by another Restate service.
invoked_by: DataType::LargeUtf8,

/// The name of the invoking service. Or `null` if invoked externally.
invoked_by_service_name: DataType::LargeUtf8,

/// The caller [Invocation ID](/operate/invocation#invocation-identifier) if the service was
/// invoked by another Restate service. Or `null` if invoked externally.
invoked_by_id: DataType::LargeUtf8,

/// The caller invocation target if the service was invoked by another Restate service. Or
/// `null` if invoked externally.
invoked_by_target: DataType::LargeUtf8,

/// The opaque service deployment ID that has been committed for this invocation; this is set
/// after the first journal entry is stored for this invocation.
pinned_deployment_id: DataType::LargeUtf8,

/// The ID of the trace that is assigned to this invocation. Only relevant when tracing is
/// enabled.
trace_id: DataType::LargeUtf8,

/// The number of journal entries durably logged for this invocation.
journal_size: DataType::UInt32,

/// Timestamp indicating the start of this invocation.
created_at: DataType::Date64,

/// Timestamp indicating the last state transition. For example, last time the status changed
/// from `invoked` to `suspended`.
modified_at: DataType::Date64,
));
38 changes: 28 additions & 10 deletions crates/storage-query-datafusion/src/journal/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,37 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(journal(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

index "The index of this journal entry.": DataType::UInt32,
entry_type "The entry type. You can check all the available entry types in [`entries.rs`](https://github.com/restatedev/restate/blob/main/crates/types/src/journal/entries.rs).": DataType::LargeUtf8,
name "The name of the entry supplied by the user, if any.": DataType::LargeUtf8,
/// [Invocation ID](/operate/invocation#invocation-identifier).
id: DataType::LargeUtf8,

completed "Indicates whether this journal entry has been completed; this is only valid for some entry types.": DataType::Boolean,
/// The index of this journal entry.
index: DataType::UInt32,

invoked_id "If this entry represents an outbound invocation, indicates the ID of that invocation.": DataType::LargeUtf8,
invoked_target "If this entry represents an outbound invocation, indicates the invocation Target. Format for plain services: `ServiceName/HandlerName`, e.g. `Greeter/greet`. Format for Virtual Objects/Workflows: `VirtualObjectName/Key/HandlerName`, e.g. `Greeter/Francesco/greet`.": DataType::LargeUtf8,
/// The entry type. You can check all the available entry types in [`entries.rs`](https://github.com/restatedev/restate/blob/main/crates/types/src/journal/entries.rs).
entry_type: DataType::LargeUtf8,

sleep_wakeup_at "If this entry represents a sleep, indicates wakeup time.": DataType::Date64,
/// The name of the entry supplied by the user, if any.
name: DataType::LargeUtf8,

raw "Raw binary representation of the entry. Check the [service protocol](https://github.com/restatedev/service-protocol) for more details to decode it.": DataType::LargeBinary,
/// Indicates whether this journal entry has been completed; this is only valid for some entry
/// types.
completed: DataType::Boolean,

/// If this entry represents an outbound invocation, indicates the ID of that invocation.
invoked_id: DataType::LargeUtf8,

/// If this entry represents an outbound invocation, indicates the invocation Target. Format
/// for plain services: `ServiceName/HandlerName`, e.g. `Greeter/greet`. Format for
/// Virtual Objects/Workflows: `VirtualObjectName/Key/HandlerName`, e.g. `Greeter/Francesco/greet`.
invoked_target: DataType::LargeUtf8,

/// If this entry represents a sleep, indicates wakeup time.
sleep_wakeup_at: DataType::Date64,

/// Raw binary representation of the entry. Check the [service protocol](https://github.com/restatedev/service-protocol)
/// for more details to decode it.
raw: DataType::LargeBinary,
));
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(keyed_service_status(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

service_name "The name for the invoked virtual object/workflow.": DataType::LargeUtf8,
service_key "The key of the virtual object/workflow.": DataType::LargeUtf8,
/// The name for the invoked virtual object/workflow.
service_name: DataType::LargeUtf8,

invocation_id "[Invocation ID](/operate/invocation#invocation-identifier).": DataType::LargeUtf8,
/// The key of the virtual object/workflow.
service_key: DataType::LargeUtf8,

/// [Invocation ID](/operate/invocation#invocation-identifier).
invocation_id: DataType::LargeUtf8,
));
28 changes: 20 additions & 8 deletions crates/storage-query-datafusion/src/promise/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(promise(
partition_key "Internal column that is used for partitioning the services invocations. Can be ignored.": DataType::UInt64,
/// Internal column that is used for partitioning the services invocations. Can be ignored.
partition_key: DataType::UInt64,

service_name "The name for the workflow.": DataType::LargeUtf8,
service_key "The key of the virtual workflow.": DataType::LargeUtf8,
/// The name for the workflow.
service_name: DataType::LargeUtf8,

key "The promise key.": DataType::LargeUtf8,
completed "True if the promise was completed.": DataType::Boolean,
/// The key of the virtual workflow.
service_key: DataType::LargeUtf8,

completion_success_value "The completion success, if any.": DataType::LargeBinary,
completion_success_value_utf8 "The completion success as UTF-8 string, if any.": DataType::LargeUtf8,
completion_failure "The completion failure, if any.": DataType::LargeUtf8,
/// The promise key.
key: DataType::LargeUtf8,

/// True if the promise was completed.
completed: DataType::Boolean,

/// The completion success, if any.
completion_success_value: DataType::LargeBinary,

/// The completion success as UTF-8 string, if any.
completion_success_value_utf8: DataType::LargeUtf8,

/// The completion failure, if any.
completion_failure: DataType::LargeUtf8,
));
17 changes: 12 additions & 5 deletions crates/storage-query-datafusion/src/service/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ use crate::table_macro::*;
use datafusion::arrow::datatypes::DataType;

define_table!(service(
name "The name of the registered user service.": DataType::LargeUtf8,
revision "The latest deployed revision.": DataType::UInt64,
/// The name of the registered user service.
name: DataType::LargeUtf8,

public "Whether the service is accessible through the ingress endpoint or not.": DataType::Boolean,
/// The latest deployed revision.
revision: DataType::UInt64,

ty "The service type. Either `service` or `virtual_object` or `workflow`.": DataType::LargeUtf8,
deployment_id "The ID of the latest deployment": DataType::LargeUtf8,
/// Whether the service is accessible through the ingress endpoint or not.
public: DataType::Boolean,

/// The service type. Either `service` or `virtual_object` or `workflow`.
ty: DataType::LargeUtf8,

/// The ID of the latest deployment
deployment_id: DataType::LargeUtf8,
));
Loading

0 comments on commit 1dd4580

Please sign in to comment.