mirror of
https://github.com/inexio/thola.git
synced 2026-10-24 03:08:55 +03:00
26 lines
826 B
Go
26 lines
826 B
Go
package request
|
|
|
|
import (
|
|
"context"
|
|
"github.com/inexio/thola/internal/network"
|
|
)
|
|
|
|
// Request is the interface which all requests must implement.
|
|
type Request interface {
|
|
// HandlePreProcessError implements request specific error handling (e.g. sets state to UNKNOWN and exit code to 3 in case
|
|
// that the request is a check request).
|
|
// Always call HandlePreProcessError if you want to correctly exit with an error before you call the process function
|
|
// on a request.
|
|
HandlePreProcessError(error) (Response, error)
|
|
|
|
validate(ctx context.Context) error
|
|
getTimeout() *int
|
|
setupConnection(ctx context.Context) (*network.RequestDeviceConnection, error)
|
|
process(ctx context.Context) (Response, error)
|
|
}
|
|
|
|
// Response is a generic interface that is returned by any Request.
|
|
type Response interface {
|
|
GetExitCode() int
|
|
}
|