Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdmissionController ¶
type AdmissionController interface { // Admit transactionally clears an operation to be performed. Admit(context.Context, *pb.InProgressOperation) (AdmissionRelease, error) // CanAdmit optimistically determines if there's capacity to run an operation. CanAdmit(context.Context, *pb.InProgressOperation) error }
AdmissionController determines if an operation can be processed.
func NewCountAdmissionController ¶
func NewCountAdmissionController(ctx context.Context, name string, capacity int, tokenFunc func(*pb.InProgressOperation) int) AdmissionController
NewCountAdmissionController creates an admission controller based on a token counter.
func NewThreadAdmissionController ¶
func NewThreadAdmissionController(ctx context.Context, name string, capacity int) AdmissionController
NewThreadAdmissionController creates an admission controller based on a thread pool size.
type AdmissionRelease ¶
type AdmissionRelease interface { // Release the tokens. Subsequent calls have no effect. Release(context.Context) error }
AdmissionRelease releases the tokens that were acquired for the operation.
type Handle ¶
type Handle interface { // SetStatus on the operation. SetStatus(label string, currentValue int, targetValue int) // GetName returns the name of the operation. GetName() string // Get the current state of the operation. This method returns the cached // version of the operation data. Get() (*pb.InProgressOperation, error) // Finish the operation. Finish(data proto.Message) (*pb.InProgressOperation, error) // Update the operation with new data with throttling. Good for frequent updates. Update(data proto.Message, statusLabel string, currentValue int, targetValue int) // UpdateImmediately the operation with new data immediately. UpdateImmediately(data proto.Message, statusLabel string, currentValue int, targetValue int) (*pb.InProgressOperation, error) }
Handle mutates operations.
type Handler ¶
type Handler interface { // ExecuteOperation runs an attempt to process an operation. ExecuteOperation(Handle) error // ExecuteOperationRollback runs an attempt to rollback the operation that failed. ExecuteOperationRollback(Handle) error }
Handler handles callback events when an operation is requested to be handled by the server.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener creates an operation polling loop and auto responder.
func NewListener ¶
func NewListener(action string, clients *appmain.Clients, interval time.Duration, admissionController AdmissionController) *Listener
NewListener creates an operation listener.
func (*Listener) Accept ¶
func (l *Listener) Accept(ctx context.Context, op *pb.InProgressOperation) (*pb.InProgressOperation, error)
Accept an operation to work on.
Click to show internal directories.
Click to hide internal directories.