github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/admin/commands/command.go (about)

     1  package commands
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/onflow/flow-go/admin"
     7  )
     8  
     9  // AdminCommand defines the interface expected for admin command handlers.
    10  type AdminCommand interface {
    11  	// Validator is responsible for validating the input of a command, available in
    12  	// the Data field of the request argument. By convention, Validator may set the
    13  	// ValidatorData field on the request, and this will persist when the request
    14  	// is passed to Handler.
    15  	//
    16  	// Returns admin.InvalidAdminReqError if request validation fails.
    17  	// Any error returned will abort the command execution.
    18  	// Expected errors will be returned to the caller with InvalidArg error code.
    19  	// Unexpected errors will be returned with Internal error code, but will not be otherwise propagated.
    20  	Validator(request *admin.CommandRequest) error
    21  
    22  	// Handler is responsible for handling the request. It applies any state
    23  	// changes associated with the request and returns any values which should
    24  	// be displayed to the initiator of the request.
    25  	//
    26  	// No errors are expected during normal operation.
    27  	// If any error is returned, the command was aborted.
    28  	// Unexpected errors will be returned with Internal error code, but will not be otherwise propagated.
    29  	Handler(ctx context.Context, request *admin.CommandRequest) (any, error)
    30  }