Documentation
¶
Index ¶
- Constants
- Variables
- type APIServer
- func (a *APIServer) ForgetSentMessages()
- func (srv *APIServer) HandleDashboard(c *gin.Context)
- func (srv *APIServer) HandleDashboardName(c *gin.Context)
- func (srv *APIServer) HandleEvent(c *gin.Context)
- func (srv *APIServer) HandleMessage(c *gin.Context)
- func (srv *APIServer) HandleReplicaPost(c *gin.Context)
- func (d *APIServer) RestartAll() error
- func (d *APIServer) RestartReplica(replica types.ReplicaID) error
- func (a *APIServer) SendMessage(msg *types.Message) error
- func (d *APIServer) SendTimeout(t *types.ReplicaTimeout) error
- func (a *APIServer) Start()
- func (d *APIServer) StartReplica(replica types.ReplicaID) error
- func (a *APIServer) Stop()
- func (d *APIServer) StopReplica(replica types.ReplicaID) error
- type DashboardRouter
Constants ¶
const DefaultAddr = "0.0.0.0:7074"
DefaultAddr is the default address of the APIServer
Variables ¶
var ( // ErrDestUnknown is returned when a message is asked to be dispatched to an unknown replicas ErrDestUnknown = errors.New("destination unknown") // ErrFailedMarshal is returned when the message could not be marshalled ErrFailedMarshal = errors.New("failed to marshal data") // ErrDuplicateDispatch is returned when a message already sent is being dispatched again ErrDuplicateDispatch = errors.New("message already dispatched") // ErrSendFailed is returned when the request could not be created ErrSendFailed = errors.New("sending failed") // ErrResponseReadFail is returned when the response to the request could not be read ErrResponseReadFail = errors.New("failed to read response") // ErrBadResponse is returned when the request did not receive a 2** response ErrBadResponse = errors.New("bad response") )
Functions ¶
This section is empty.
Types ¶
type APIServer ¶
type APIServer struct {
*types.BaseService
// contains filtered or unexported fields
}
APIServer runs a HTTP server to receive messages from the replicas and provide an interactive dashboard
func NewAPIServer ¶
func NewAPIServer(ctx *context.RootContext, messageParser types.MessageParser, dashboard DashboardRouter) *APIServer
NewAPIServer instantiates APIServer
func (*APIServer) ForgetSentMessages ¶ added in v0.2.1
func (a *APIServer) ForgetSentMessages()
func (*APIServer) HandleDashboard ¶
HandleDashboard is the handler for the router `/dashboard`
func (*APIServer) HandleDashboardName ¶
HandleDashboardName is the handler for `/dashboard/name` route of the APIServer
func (*APIServer) HandleEvent ¶
HandleEvent is the handler for the router `/event` . The route is used by replicas to send events to the scheduler
func (*APIServer) HandleMessage ¶
HandleMessage is the handler for the route `/message` which is used by replicas to send messages
func (*APIServer) HandleReplicaPost ¶
HandleReplicaPost is the handler for the route `/replica` for a POST request. The route is used by replicas to register and start communicating with the scheduler
func (*APIServer) RestartAll ¶ added in v0.2.1
RestartAll restarts all the replicas
func (*APIServer) RestartReplica ¶ added in v0.2.1
RestartReplica should be called to direct the replica to restart
func (*APIServer) SendMessage ¶ added in v0.2.1
func (*APIServer) SendTimeout ¶ added in v0.2.1
func (d *APIServer) SendTimeout(t *types.ReplicaTimeout) error
Send a timeout message to the replica This is the equivalent of ending a timeout at the replica
func (*APIServer) Start ¶
func (a *APIServer) Start()
Start starts the APIServer and implements Service
func (*APIServer) StartReplica ¶ added in v0.2.1
StartReplica should be called to direct the replica to start running
type DashboardRouter ¶
type DashboardRouter interface {
// Name should return the key for the dashboard type
Name() string
// SetupRouter should set up the routes for the dashboard
SetupRouter(*gin.RouterGroup)
}
DashboardRouter for handling routes that are specific to the dashboard. The APIServer will be initialized with an instance of DashboardRouter. The dashboard routes depends on the mode in which the scheduler is run.