publicapi

package
v0.3.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 TailFile

func TailFile(count int, path string) ([]byte, error)

use "-1" as count for just last line

Types

type APIClient

type APIClient struct {
	BaseURI        *url.URL
	DefaultHeaders map[string]string

	Client *http.Client
}

APIClient is a utility for interacting with a node's API server.

func NewAPIClient

func NewAPIClient(host string, port uint16, path ...string) *APIClient

NewAPIClient returns a new client for a node's API server.

func (*APIClient) Alive

func (apiClient *APIClient) Alive(ctx context.Context) (bool, error)

Alive calls the node's API server health check.

func (*APIClient) Post

func (apiClient *APIClient) Post(ctx context.Context, api string, reqData, resData interface{}) error

func (*APIClient) Version

func (apiClient *APIClient) Version(ctx context.Context) (*model.BuildVersionInfo, error)

type APIServer

type APIServer struct {
	Address string
	Port    uint16
	// contains filtered or unexported fields
}

APIServer configures a node's public REST API.

func NewAPIServer

func NewAPIServer(params APIServerParams) (*APIServer, error)

func (*APIServer) GetURI

func (apiServer *APIServer) GetURI() *url.URL

GetURI returns the HTTP URI that the server is listening on.

func (*APIServer) ListenAndServe

func (apiServer *APIServer) ListenAndServe(ctx context.Context, cm *system.CleanupManager) error
@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(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 HandlerConfig

type HandlerConfig struct {
	URI                   string
	Handler               http.Handler
	RequestHandlerTimeout time.Duration
	Raw                   bool // don't wrap the handler with middleware
}

type VersionRequest

type VersionRequest struct {
	ClientID string `json:"client_id" example:"ac13188e93c97a9c2e7cf8e86c7313156a73436036f30da1ececc2ce79f9ea51"`
}

type VersionResponse

type VersionResponse struct {
	VersionInfo *model.BuildVersionInfo `json:"build_version_info"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL