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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ web/app/node_modules
*.sqlite-wal

custom-gcl

# Docs build artifacts
docs/build/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runWorker(ctx context.Context, mb backend.Backend) {

### Backend

The backend is responsible for persisting the workflow events. Currently there is an in-memory backend implementation for testing, one using [SQLite](http://sqlite.org), one using MySql, and one using Redis.
The backend is responsible for persisting the workflow events. Currently there is an in-memory backend implementation for testing, one using [SQLite](http://sqlite.org), one using MySQL, one using PostgreSQL, and one using Redis.

```go
b := sqlite.NewSqliteBackend("simple.sqlite")
Expand Down
8 changes: 8 additions & 0 deletions backend/postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# PostgreSQL backend

## Adding a migration

1. Install [golang-migrate/migrate](https://github.com/golang-migrate/migrate)
1. ```bash
migrate create -ext sql -dir ./db/migrations -seq <name>
```
27 changes: 26 additions & 1 deletion docs/source/includes/_backends.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Backends

There are three backend implementations maintained in this repository. Some backend implementations have custom options and all of them accept:
There are four backend implementations maintained in this repository. Some backend implementations have custom options and all of them accept:

- `WithStickyTimeout(timeout time.Duration)` - Set the timeout for sticky tasks. Defaults to 30 seconds
- `WithWorkflowLockTimeout(timeout time.Duration)` - Set the timeout for workflow task locks. Defaults to 1 minute
Expand Down Expand Up @@ -61,6 +61,31 @@ See `migrations/mysql` for the schema and migrations. Main tables:
- `activities` - Queue of pending activities
- `attributes` - Payloads of events

## PostgreSQL

```go
func NewPostgresBackend(host string, port int, user, password, database string, opts ...option)
```

Create a new PostgreSQL backend instance with `NewPostgresBackend`.

### Options

- `WithPostgresOptions(f func(db *sql.DB))` - Apply custom options to the PostgreSQL database connection
- `WithApplyMigrations(applyMigrations bool)` - Set whether migrations should be applied on startup. Defaults to `true`
- `WithBackendOptions(opts ...backend.BackendOption)` - Apply generic backend options


### Schema

See `migrations/postgres` for the schema and migrations. Main tables:

- `instances` - Tracks workflow instances. Functions as instance queue joined with `pending_events`
- `pending_events` - Pending events for workflow instances
- `history` - History for workflow instances
- `activities` - Queue of pending activities
- `attributes` - Payloads of events

## Redis

```go
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ go-workflows is an embedded engine for orchestrating long running processes or "

It borrows heavily from [Temporal](https://github.com/temporalio/temporal) (and since it's a fork also [Cadence](https://github.com/uber/cadence)) as well as Azure's [Durable Task Framework (DTFx)](https://github.com/Azure/durabletask). Workflows are written in plain Go.

go-workflows support pluggable backends with official implementations for Sqlite, MySql, and Redis.
go-workflows support pluggable backends with official implementations for Sqlite, MySQL, PostgreSQL, and Redis.

See also the following blog posts:

Expand Down
Loading