package module
Version: v0.1.7 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2021 License: GPL-3.0 Imports: 25 Imported by: 0



link to docs

Minimalist serverless workflow framework built on top of Google Cloud.

It allows you to:

  • Run your workflows for free
    • Cloud Run: 1 million req/month are free
    • Cloud Tasks: 1 million req/month is free
    • Firestore: 1 GB storage + 20,000 ops/day are free
  • Create fully documented, validated, readable, testable and actually working workflows in minutes, rather than weeks.
    • Autogenerated type-safe API to handle incoming events.
    • Autogenerated Swagger documentation for API above.
    • Autogenerated Flow Diagram to validate logic with stakeholders.
  • Understand the logic behind your workflows by writing them as a code.
  • Run concurrent workflows in a Go style, using Goroutines and wait conditions.
  • Fix your workflows on the fly, while they are running (useful for singleton workflows runniing in a loop)

Just look at example app:


If you don't like this framework - you can create your own using:

It's a core piece of this framework that can be adapted to a wider amount of use-cases.




This section is empty.


This section is empty.


func SwaggerDoc added in v0.1.4

func SwaggerDoc(baseurl string, wfName string, wf func() async.WorkflowState) (interface{}, error)


type Config

type Config struct {
	GCloudProjectID      string
	GCloudLocationID     string
	GCloudTasksQueueName string
	BasePublicURL        string
	CORS                 bool
	Collection           string
	SignSecret           string

type DBWorkflow

type DBWorkflow struct {
	Meta     async.State
	State    interface{} // json body of workflow state
	LockTill time.Time   // optimistic locking

type DBWorkflowLog

type DBWorkflowLog struct {
	Meta         async.State
	State        interface{} // json body of workflow state
	Time         time.Time
	ExecDuration time.Duration
	Input        interface{}
	Output       interface{}
	Callback     *async.CallbackRequest

type FirestoreEngine

type FirestoreEngine struct {
	Scheduler  *GTasksScheduler
	DB         *firestore.Client
	Collection string
	Workflows  map[string]func() async.WorkflowState

func (FirestoreEngine) Get

func (fs FirestoreEngine) Get(ctx context.Context, id string) (*DBWorkflow, error)

func (FirestoreEngine) HandleCallback

func (fs FirestoreEngine) HandleCallback(ctx context.Context, id string, cb async.CallbackRequest, input interface{}) (interface{}, error)

func (FirestoreEngine) HandleEvent

func (fs FirestoreEngine) HandleEvent(ctx context.Context, id string, name string, input interface{}) (interface{}, error)

func (FirestoreEngine) Lock

func (fs FirestoreEngine) Lock(ctx context.Context, id string) (DBWorkflow, error)

func (FirestoreEngine) Resume

func (fs FirestoreEngine) Resume(ctx context.Context, id string) error

func (FirestoreEngine) Save added in v0.1.6

func (fs FirestoreEngine) Save(ctx context.Context, wf *DBWorkflow, s *async.WorkflowState, unlock bool) error

func (FirestoreEngine) ScheduleAndCreate

func (fs FirestoreEngine) ScheduleAndCreate(ctx context.Context, id, name string, state interface{}) error

func (FirestoreEngine) Unlock

func (fs FirestoreEngine) Unlock(ctx context.Context, id string) error

type GTasksScheduler

type GTasksScheduler struct {
	Engine      *FirestoreEngine
	C           *cloudtasks.Service
	Collection  string
	ProjectID   string
	LocationID  string
	QueueName   string
	ResumeURL   string
	CallbackURL string
	Secret      string

func (*GTasksScheduler) ResumeHandler

func (mgr *GTasksScheduler) ResumeHandler(w http.ResponseWriter, r *http.Request)

func (*GTasksScheduler) Schedule

func (mgr *GTasksScheduler) Schedule(ctx context.Context, id string, delay time.Duration) error

in this demo we resume workflows right inside the http handler. we use this scheduler only for redundancy in case resume will fail for some reason in http handler.

func (*GTasksScheduler) Setup

func (*GTasksScheduler) Teardown

func (mgr *GTasksScheduler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error

func (*GTasksScheduler) TimeoutHandler

func (mgr *GTasksScheduler) TimeoutHandler(w http.ResponseWriter, r *http.Request)

type GTasksSchedulerData

type GTasksSchedulerData struct {
	ID string

type GraphCtx

type GraphCtx struct {
	Parent string
	Prev   []string
	Break  []string

type Grapher

type Grapher struct {
	// contains filtered or unexported fields

func (*Grapher) AddEdge

func (g *Grapher) AddEdge(from string, to string)

func (*Grapher) AddEdges

func (g *Grapher) AddEdges(from []string, to string)

func (*Grapher) Dot

func (g *Grapher) Dot(s async.Stmt) string

func (*Grapher) Walk

func (g *Grapher) Walk(s async.Stmt, ctx GraphCtx) GraphCtx

type ResumeRequest

type ResumeRequest struct {
	ID        string
	Signature string

func (ResumeRequest) HMAC added in v0.1.2

func (req ResumeRequest) HMAC(secret []byte) string

type Server

type Server struct {
	Router    *mux.Router
	Engine    *FirestoreEngine
	Scheduler *GTasksScheduler

func NewServer

func NewServer(cfg Config, workflows map[string]func() async.WorkflowState) (*Server, error)

func (*Server) Timeout added in v0.1.2

func (s *Server) Timeout(name string, dur time.Duration, stmts ...async.Stmt) async.Event

type TimeoutHandler

type TimeoutHandler struct {
	Duration time.Duration
	// contains filtered or unexported fields

func (*TimeoutHandler) Handle

func (t *TimeoutHandler) Handle(ctx context.Context, req async.CallbackRequest, input interface{}) (interface{}, error)

func (TimeoutHandler) MarshalJSON

func (s TimeoutHandler) MarshalJSON() ([]byte, error)

func (*TimeoutHandler) Setup

func (*TimeoutHandler) Teardown

func (t *TimeoutHandler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error

type TimeoutReq added in v0.1.2

type TimeoutReq struct {
	Req       async.CallbackRequest
	Signature string

func (TimeoutReq) HMAC added in v0.1.2

func (req TimeoutReq) HMAC(secret []byte) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL