Documentation
¶
Index ¶
- func Event(role, name string, handler interface{}, ss ...async.Stmt) async.Event
- func SwaggerDoc(baseurl string, wfName string, wf func() async.WorkflowState) (interface{}, error)
- type Config
- type DBWorkflow
- type DBWorkflowLog
- type Empty
- type ErrValidate
- type FirestoreEngine
- 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) Save(ctx context.Context, wf *DBWorkflow, s *async.WorkflowState, unlock bool) 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, delay time.Duration) error
- func (mgr *GTasksScheduler) Setup(ctx context.Context, r async.CallbackRequest, del time.Duration) (string, error)
- func (mgr *GTasksScheduler) Teardown(ctx context.Context, req async.CallbackRequest, handled bool) error
- 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
- type TimeoutReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SwaggerDoc ¶ added in v0.1.4
func SwaggerDoc(baseurl string, wfName string, wf func() async.WorkflowState) (interface{}, error)
Types ¶
type DBWorkflow ¶
type DBWorkflowLog ¶
type ErrValidate ¶ added in v0.1.6
func ValidateErr ¶ added in v0.1.6
func ValidateErr(path, format string, params ...interface{}) ErrValidate
func (ErrValidate) Error ¶ added in v0.1.6
func (e ErrValidate) Error() string
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 (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
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 ¶
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, r 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) TimeoutHandler ¶
func (mgr *GTasksScheduler) TimeoutHandler(w http.ResponseWriter, r *http.Request)
type GTasksSchedulerData ¶
type GTasksSchedulerData struct {
ID string
}
type ReflectEvent ¶
type ReflectEvent struct {
Role string
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 ¶
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 (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
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
Click to show internal directories.
Click to hide internal directories.