Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 176 additions & 0 deletions docs/libraries/workflow/DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Developing

## View realtime logs

```logql
{name="monolith-workflow-worker"}
```

## Fixing errors

If you run in to a too many retries error on a workflow, then:

1. Update the workflow code
2. Re-wake the workflow
3. Wait for the workflow to poll for new changes

For a single workflow:

```sql
UPDATE db_workflow.workflows SET wake_immediate = true WHERE workflow_id = 'MY_ID':uuid;
```

For all workflows of a type:

```sql
UPDATE db_workflow.workflows SET wake_immediate = true WHERE workflow_name = 'MY_NAME';
```


# Visualize entire workflow history

```sql
WITH workflow_events AS (
SELECT '1db61ba2-6271-40a5-9a38-e6fa212e6f7d'::uuid AS workflow_id
)
SELECT location, 'activity' AS t, activity_name, input, output, forgotten
FROM db_workflow.workflow_activity_events, workflow_events
WHERE
workflow_activity_events.workflow_id = workflow_events.workflow_id
UNION ALL
SELECT location, 'signal' AS t, signal_name AS name, null as input, null as output, forgotten
FROM db_workflow.workflow_signal_events, workflow_events
WHERE
workflow_signal_events.workflow_id = workflow_events.workflow_id
UNION ALL
SELECT location, 'sub_workflow' AS t, sub_workflow_id::STRING AS name, null as input, null as output, forgotten
FROM db_workflow.workflow_sub_workflow_events, workflow_events
WHERE
workflow_sub_workflow_events.workflow_id = workflow_events.workflow_id
UNION ALL
SELECT location, 'signal_send' AS t, signal_name AS name, null as input, null as output, forgotten
FROM db_workflow.workflow_signal_send_events, workflow_events
WHERE
workflow_signal_send_events.workflow_id = workflow_events.workflow_id
UNION ALL
SELECT location, 'message_send' AS t, message_name AS name, null as input, null as output, forgotten
FROM db_workflow.workflow_message_send_events, workflow_events
WHERE
workflow_message_send_events.workflow_id = workflow_events.workflow_id
UNION ALL
SELECT location, 'loop' AS t, NULL AS name, null as input, null as output, forgotten
FROM db_workflow.workflow_loop_events, workflow_events
WHERE
workflow_loop_events.workflow_id = workflow_events.workflow_id
ORDER BY location ASC;
```

## Completely delete workflow with ID

```sql
WITH workflow_ids AS (
SELECT 'WORKFLOW_ID':uuid AS workflow_id
),
delete_activity_events AS (
DELETE FROM db_workflow.workflow_activity_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_signal_events AS (
DELETE FROM db_workflow.workflow_signal_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_sub_workflow_events AS (
DELETE FROM db_workflow.workflow_sub_workflow_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_signal_send_events AS (
DELETE FROM db_workflow.workflow_signal_send_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_message_send_events AS (
DELETE FROM db_workflow.workflow_message_send_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_loop_events AS (
DELETE FROM db_workflow.workflow_loop_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_activity_errors AS (
DELETE FROM db_workflow.workflow_activity_errors
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
)
DELETE FROM db_workflow.workflows
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1;
```

## Completely delete workflow with name

```sql
WITH workflow_ids AS (
SELECT workflow_id
FROM db_workflow.workflows
WHERE workflow_name = 'WORKFLOW_NAME'
),
delete_activity_events AS (
DELETE FROM db_workflow.workflow_activity_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_signal_events AS (
DELETE FROM db_workflow.workflow_signal_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_sub_workflow_events AS (
DELETE FROM db_workflow.workflow_sub_workflow_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_signal_send_events AS (
DELETE FROM db_workflow.workflow_signal_send_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_message_send_events AS (
DELETE FROM db_workflow.workflow_message_send_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_loop_events AS (
DELETE FROM db_workflow.workflow_loop_events
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
),
delete_activity_errors AS (
DELETE FROM db_workflow.workflow_activity_errors
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1
)
DELETE FROM db_workflow.workflows
WHERE workflow_id IN (SELECT workflow_id FROM workflow_ids)
RETURNING 1;
```

## Misc

```sql
select *
from db_workflow.workflows
where workflow_name = 'backend'
order by create_ts desc;
```

```sql
select workflow_activity_errors.*
from db_workflow.workflows
inner join db_workflow.workflow_activity_errors using (workflow_id)
where workflows.workflow_name = 'backend';
```
36 changes: 0 additions & 36 deletions docs/libraries/workflow/USEFUL_QUERIES.md

This file was deleted.

2 changes: 1 addition & 1 deletion fern/definition/servers/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ types:

CreateServerRuntimeRequest:
properties:
image: uuid
build: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>

Expand Down
2 changes: 1 addition & 1 deletion fern/definition/servers/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ types:

Runtime:
properties:
image: uuid
build: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>

Expand Down
10 changes: 4 additions & 6 deletions lib/bolt/core/src/dep/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,9 @@ pub async fn build<'a, T: AsRef<str>>(ctx: &ProjectContext, opts: BuildOpts<'a,

FROM rust:1.80.0-slim AS rust

RUN apt-get update && apt-get install -y protobuf-compiler pkg-config libssl-dev g++ git

RUN apt-get install --yes libpq-dev wget
RUN wget https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz \
RUN apt-get update \
&& apt-get install --yes protobuf-compiler pkg-config libssl-dev g++ git libpq-dev wget \
&& wget https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz \
&& tar xzf sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz \
&& mv sccache-v0.2.15-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \
&& chmod +x /usr/local/bin/sccache
Expand All @@ -191,13 +190,12 @@ pub async fn build<'a, T: AsRef<str>>(ctx: &ProjectContext, opts: BuildOpts<'a,

# Build and copy all binaries from target directory into an empty image (it is not
# included in the output because of cache mount)
RUN chmod +x ./build_script.sh
RUN \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/rivet/target \
--mount=type=cache,target=/usr/rivet/oss/target \
sh -c ./build_script.sh && mkdir /usr/bin/rivet && find target/{optimization} -maxdepth 1 -type f ! -name "*.*" -exec mv {{}} /usr/bin/rivet/ \;
chmod +x ./build_script.sh && sh -c ./build_script.sh && mkdir /usr/bin/rivet && find target/{optimization} -maxdepth 1 -type f ! -name "*.*" -exec mv {{}} /usr/bin/rivet/ \;

# Create an empty image and copy binaries + test outputs to it (this is to minimize the
# size of the image)
Expand Down
2 changes: 1 addition & 1 deletion lib/convert/src/impls/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl ApiTryFrom<backend::ds::Server> for models::ServersServer {
destroyed_at: value.destroy_ts,
tags: Some(to_value(value.tags).unwrap()),
runtime: Box::new(models::ServersRuntime {
image: unwrap!(value.image_id).as_uuid(),
build: unwrap!(value.image_id).as_uuid(),
arguments: Some(value.args),
environment: Some(value.environment),
}),
Expand Down
4 changes: 2 additions & 2 deletions sdks/full/go/servers/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions sdks/full/openapi/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions sdks/full/openapi_compat/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdks/full/rust-cli/docs/ServersRuntime.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading