Documentation
¶
Index ¶
- func Event(name string, handler interface{}, ss ...async.Stmt) async.Event
- func SwaggerDocs(workflows map[string]func() async.WorkflowState) (interface{}, error)
- type Config
- type DBWorkflow
- type DBWorkflowLog
- type Empty
- type FirestoreEngine
- func (fs FirestoreEngine) Checkpoint(ctx context.Context, wf *DBWorkflow, s *async.WorkflowState, ...) func(bool) error
- func (fs FirestoreEngine) Get(ctx context.Context, id string) (*DBWorkflow, error)
- func (fs FirestoreEngine) HandleCallback(ctx context.Context, id string, cb async.CallbackRequest, input interface{}) (interface{}, error)
- func (fs FirestoreEngine) HandleEvent(ctx context.Context, id string, name string, input interface{}) (interface{}, error)
- func (fs FirestoreEngine) Lock(ctx context.Context, id string) (DBWorkflow, error)
- func (fs FirestoreEngine) Resume(ctx context.Context, id string) error
- func (fs FirestoreEngine) ScheduleAndCreate(ctx context.Context, id, name string, state interface{}) error
- func (fs FirestoreEngine) Unlock(ctx context.Context, id string) error
- type GTasksScheduler
- func (mgr *GTasksScheduler) ResumeHandler(w http.ResponseWriter, r *http.Request)
- func (mgr *GTasksScheduler) Schedule(ctx context.Context, id string) error
- func (mgr *GTasksScheduler) Setup(ctx context.Context, req async.CallbackRequest, del time.Duration) (string, error)
- func (mgr *GTasksScheduler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
- func (t *GTasksScheduler) Timeout(dur time.Duration) *TimeoutHandler
- func (mgr *GTasksScheduler) TimeoutHandler(w http.ResponseWriter, r *http.Request)
- type GTasksSchedulerData
- type GraphCtx
- type Grapher
- type ReflectEvent
- func (h *ReflectEvent) Handle(ctx context.Context, req async.CallbackRequest, input interface{}) (interface{}, error)
- func (h ReflectEvent) InputSchema() ([]byte, error)
- func (h ReflectEvent) MarshalJSON() ([]byte, error)
- func (h ReflectEvent) Schemas() (in *jsonschema.Schema, out *jsonschema.Schema, err error)
- func (t *ReflectEvent) Setup(ctx context.Context, req async.CallbackRequest) (string, error)
- func (t *ReflectEvent) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
- type ResumeRequest
- type Server
- type TimeoutHandler
- func (t *TimeoutHandler) Handle(ctx context.Context, req async.CallbackRequest, input interface{}) (interface{}, error)
- func (s TimeoutHandler) MarshalJSON() ([]byte, error)
- func (t *TimeoutHandler) Setup(ctx context.Context, req async.CallbackRequest) (string, error)
- func (t *TimeoutHandler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SwaggerDocs ¶
func SwaggerDocs(workflows map[string]func() async.WorkflowState) (interface{}, error)
Types ¶
type DBWorkflow ¶
type DBWorkflowLog ¶
type FirestoreEngine ¶
type FirestoreEngine struct {
Scheduler *GTasksScheduler
DB *firestore.Client
Collection string
Workflows map[string]func() async.WorkflowState
}
func (FirestoreEngine) Checkpoint ¶
func (fs FirestoreEngine) Checkpoint(ctx context.Context, wf *DBWorkflow, s *async.WorkflowState, cb *async.CallbackRequest, input, output interface{}) func(bool) error
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 (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) ScheduleAndCreate ¶
func (fs FirestoreEngine) ScheduleAndCreate(ctx context.Context, id, name string, state interface{}) error
type GTasksScheduler ¶
type GTasksScheduler struct {
Engine *FirestoreEngine
C *cloudtasks.Service
Collection string
ProjectID string
LocationID string
QueueName string
ResumeURL string
CallbackURL 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) 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 (mgr *GTasksScheduler) Setup(ctx context.Context, req async.CallbackRequest, del time.Duration) (string, error)
func (*GTasksScheduler) Teardown ¶
func (mgr *GTasksScheduler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
func (*GTasksScheduler) Timeout ¶
func (t *GTasksScheduler) Timeout(dur time.Duration) *TimeoutHandler
func (*GTasksScheduler) TimeoutHandler ¶
func (mgr *GTasksScheduler) TimeoutHandler(w http.ResponseWriter, r *http.Request)
type GTasksSchedulerData ¶
type GTasksSchedulerData struct {
ID string
}
type ReflectEvent ¶
type ReflectEvent struct {
Handler interface{}
}
This is an example of how to create your custom events
func (*ReflectEvent) Handle ¶
func (h *ReflectEvent) Handle(ctx context.Context, req async.CallbackRequest, input interface{}) (interface{}, error)
code that will be executed when event is received
func (ReflectEvent) InputSchema ¶
func (h ReflectEvent) InputSchema() ([]byte, error)
func (ReflectEvent) MarshalJSON ¶
func (h ReflectEvent) MarshalJSON() ([]byte, error)
func (ReflectEvent) Schemas ¶
func (h ReflectEvent) Schemas() (in *jsonschema.Schema, out *jsonschema.Schema, err error)
func (*ReflectEvent) Setup ¶
func (t *ReflectEvent) Setup(ctx context.Context, req async.CallbackRequest) (string, error)
when we will start listening for this event - Setup() will be called for us to setup this event on external services
func (*ReflectEvent) Teardown ¶
func (t *ReflectEvent) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
when we will stop listening for this event - Teardown() will be called for us to remove this event on external services
type ResumeRequest ¶
type ResumeRequest struct {
ID string
}
type Server ¶
type Server struct {
Engine *FirestoreEngine
Router *mux.Router
}
func (Server) SimpleEventHandler ¶
func (s Server) SimpleEventHandler(w http.ResponseWriter, r *http.Request)
Receive event and forward it to workflow engine
type TimeoutHandler ¶
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 (t *TimeoutHandler) Setup(ctx context.Context, req async.CallbackRequest) (string, error)
func (*TimeoutHandler) Teardown ¶
func (t *TimeoutHandler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
Click to show internal directories.
Click to hide internal directories.