github.com/leg100/ots@v0.0.7-0.20210919080622-034055ced4bd/events.go (about) 1 package ots 2 3 const ( 4 OrganizationCreated EventType = "organization_created" 5 OrganizationDeleted EventType = "organization_deleted" 6 WorkspaceCreated EventType = "workspace_created" 7 WorkspaceDeleted EventType = "workspace_deleted" 8 RunCreated EventType = "run_created" 9 RunCompleted EventType = "run_completed" 10 RunCanceled EventType = "run_canceled" 11 RunApplied EventType = "run_applied" 12 RunPlanned EventType = "run_planned" 13 RunPlannedAndFinished EventType = "run_planned_and_finished" 14 PlanQueued EventType = "plan_queued" 15 ApplyQueued EventType = "apply_queued" 16 ) 17 18 type EventType string 19 20 type Event struct { 21 Type EventType 22 Payload interface{} 23 } 24 25 type EventService interface { 26 Publish(Event) 27 Subscribe(id string) Subscription 28 } 29 30 // Subscription represents a stream of events for a subscriber 31 type Subscription interface { 32 // Event stream for all subscriber's event. 33 C() <-chan Event 34 35 // Closes the event stream channel and disconnects from the event service. 36 Close() error 37 }