Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateHealthData() types.HealthInfo
- func HTTPError(ctx context.Context, res http.ResponseWriter, err error, statusCode int)
- func MountUsage(path string) (disk types.MountStatus)
- func SignRequest(reqData any) (req signedRequest, err error)
- func TailFile(count int, path string) ([]byte, error)
- func UnmarshalSigned[PayloadType ContainsClientID](ctx context.Context, body io.Reader) (PayloadType, error)
- type APIClient
- func (apiClient *APIClient) Alive(ctx context.Context) (bool, error)
- func (apiClient *APIClient) Post(ctx context.Context, api string, reqData, resData interface{}) error
- func (apiClient *APIClient) PostSigned(ctx context.Context, api string, reqData, resData interface{}) error
- func (apiClient *APIClient) Version(ctx context.Context) (*model.BuildVersionInfo, error)
- type APIServer
- type APIServerConfig
- type APIServerParams
- type ContainsClientID
- type HandlerConfig
- type SignedRequest
- type VersionRequest
- type VersionResponse
Constants ¶
View Source
const LegacyAPIPrefix = ""
View Source
const V1APIPrefix = "/api/v1"
Variables ¶
View Source
var DefaultAPIServerConfig = APIServerConfig{ ReadHeaderTimeout: 10 * time.Second, ReadTimeout: 20 * time.Second, WriteTimeout: 20 * time.Second, RequestHandlerTimeout: 30 * time.Second, RequestHandlerTimeoutByURI: map[string]time.Duration{}, MaxBytesToReadInBody: 10 * datasize.MB, }
View Source
var LINESOFLOGTOPRINT = 100
Functions ¶
func GenerateHealthData ¶
func GenerateHealthData() types.HealthInfo
func MountUsage ¶
func MountUsage(path string) (disk types.MountStatus)
Function to get disk usage of path/disk
func SignRequest ¶ added in v0.3.26
func UnmarshalSigned ¶ added in v0.3.26
Types ¶
type APIClient ¶
APIClient is a utility for interacting with a node's API server against v1 APIs.
func NewAPIClient ¶
NewAPIClient returns a new client for a node's API server against v1 APIs the client will use /api/v1 path by default is no custom path is defined
func (*APIClient) PostSigned ¶ added in v0.3.26
type APIServer ¶
APIServer configures a node's public REST API.
func NewAPIServer ¶
func NewAPIServer(params APIServerParams) (*APIServer, error)
func (*APIServer) ListenAndServe ¶
@title Bacalhau API @description This page is the reference of the Bacalhau REST API. Project docs are available at https://docs.bacalhau.org/. Find more information about Bacalhau at https://github.com/bacalhau-project/bacalhau. @contact.name Bacalhau Team @contact.url https://github.com/bacalhau-project/bacalhau @contact.email team@bacalhau.org @license.name Apache 2.0 @license.url https://github.com/bacalhau-project/bacalhau/blob/main/LICENSE @host bootstrap.production.bacalhau.org:1234 @BasePath / @schemes http
ListenAndServe listens for and serves HTTP requests against the API server.
func (*APIServer) RegisterHandlers ¶
func (apiServer *APIServer) RegisterHandlers(apiPrefix string, config ...HandlerConfig) error
type APIServerConfig ¶
type APIServerConfig struct { // These are TCP connection deadlines and not HTTP timeouts. They don't control the time it takes for our handlers // to complete. Deadlines operate on the connection, so our server will fail to return a result only after // the handlers try to access connection properties ReadHeaderTimeout time.Duration // the amount of time allowed to read request headers ReadTimeout time.Duration // the maximum duration for reading the entire request, including the body WriteTimeout time.Duration // the maximum duration before timing out writes of the response // This represents maximum duration for handlers to complete, or else fail the request with 503 error code. RequestHandlerTimeout time.Duration RequestHandlerTimeoutByURI map[string]time.Duration // MaxBytesToReadInBody is used by safeHandlerFuncWrapper as the max size of body MaxBytesToReadInBody datasize.ByteSize }
type APIServerParams ¶
type APIServerParams struct { Address string Port uint16 Host host.Host NodeInfoProvider model.NodeInfoProvider Config APIServerConfig }
type ContainsClientID ¶ added in v0.3.26
type ContainsClientID interface {
GetClientID() string
}
type HandlerConfig ¶
type SignedRequest ¶ added in v0.3.26
type SignedRequest[PayloadType ContainsClientID] struct { // The data needed to cancel a running job on the network Payload PayloadType `json:"payload" validate:"required"` // A base64-encoded signature of the data, signed by the client: ClientSignature string `json:"signature" validate:"required"` // The base64-encoded public key of the client: ClientPublicKey string `json:"client_public_key" validate:"required"` }
A strongly-typed signed request. We use this type only in our documentation to allow clients to understand the correct type of the payload.
type VersionRequest ¶
type VersionRequest struct {
ClientID string `json:"client_id" example:"ac13188e93c97a9c2e7cf8e86c7313156a73436036f30da1ececc2ce79f9ea51"`
}
type VersionResponse ¶
type VersionResponse struct {
VersionInfo *model.BuildVersionInfo `json:"build_version_info"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.