services

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 27 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

HTTPClient will be set to a default httpclient if not set

View Source
var HTTPSigner *httpsig.Signer

HTTPSigner is used to sign requests based on the RFC draft specification https://tools.ietf.org/html/draft-cavage-http-signatures-06

View Source
var LoadOptions = struct {
	WithStatus LoadOptionFunc
}{
	WithStatus: loadServiceStatus,
}

LoadOptions provides all options on service loads functions

View Source
var NewClient func([]sdk.Service) Client = NewDefaultClient

Functions

func Delete

func Delete(db gorp.SqlExecutor, s *sdk.Service) error

Delete a service.

func DoRequest

func DoRequest(ctx context.Context, srvs []sdk.Service, method, path string, args []byte, mods ...cdsclient.RequestModifier) ([]byte, http.Header, int, error)

DoRequest performs an http request on a service

func FindDeadServices

func FindDeadServices(ctx context.Context, db gorp.SqlExecutor, t time.Duration) ([]sdk.Service, error)

FindDeadServices returns services which haven't heart since th duration

func GetCDNPublicHTTPAdress

func GetCDNPublicHTTPAdress(ctx context.Context, db gorp.SqlExecutor) (string, error)

func GetCDNPublicTCPAdress

func GetCDNPublicTCPAdress(ctx context.Context, db gorp.SqlExecutor) (string, bool, error)

func Initialize

func Initialize(c context.Context, dbF *database.DBConnectionFactory, goRoutines *sdk.GoRoutines)

Initialize the service package

func Insert

Insert a service in database.

func KillDeadServices

func KillDeadServices(ctx context.Context, dbFunc func() *gorp.DbMap)

KillDeadServices must be run as a goroutine. It Deletes all dead workers

func LoadAll

func LoadAll(ctx context.Context, db gorp.SqlExecutor, opts ...LoadOptionFunc) ([]sdk.Service, error)

LoadAll returns all services in database.

func LoadAllByType

func LoadAllByType(ctx context.Context, db gorp.SqlExecutor, typeService string, opts ...LoadOptionFunc) ([]sdk.Service, error)

LoadAllByType returns all services with given type.

func LoadByConsumerID

func LoadByConsumerID(ctx context.Context, db gorp.SqlExecutor, consumerID string) (*sdk.Service, error)

LoadByConsumerID returns a service by its consumer id.

func LoadByID

func LoadByID(ctx context.Context, db gorp.SqlExecutor, id int64) (*sdk.Service, error)

LoadByID returns a service by its id.

func LoadByName

func LoadByName(ctx context.Context, db gorp.SqlExecutor, name string, opts ...LoadOptionFunc) (*sdk.Service, error)

LoadByName returns a service by its name.

func LoadByNameAndType

func LoadByNameAndType(ctx context.Context, db gorp.SqlExecutor, name, stype string) (*sdk.Service, error)

LoadByNameAndType returns a service by its name and type.

func PostBinary

func PostBinary(ctx context.Context, srvs []sdk.Service, path string, r io.Reader, out interface{}, mods ...cdsclient.RequestModifier) (int, error)

PostBinary

func Update

Update a service in database.

func UpdateLastHeartbeat added in v0.52.0

func UpdateLastHeartbeat(ctx context.Context, db gorpmapper.SqlExecutorWithTx, s *sdk.Service) error

UpdateLastHeartbeat a service in database.

func UpsertStatus

func UpsertStatus(ctx context.Context, db gorpmapper.SqlExecutorWithTx, s sdk.Service, authSessionID string) error

UpsertStatus insert or update monitoring status

Types

type Client

type Client interface {
	// DoJSONRequest performs an http request on a service
	DoJSONRequest(ctx context.Context, method, path string, in interface{}, out interface{}, mods ...cdsclient.RequestModifier) (http.Header, int, error)
	// DoMultiPartRequest performs an http request on a service with multipart  tar file + json field
	DoMultiPartRequest(ctx context.Context, method, path string, multiPartData *MultiPartData, in interface{}, out interface{}, mods ...cdsclient.RequestModifier) (int, error)
	// StreamRequest performs an hhtp request and stream the response
	StreamRequest(ctx context.Context, method, path string, in interface{}, mods ...cdsclient.RequestModifier) (io.Reader, http.Header, int, error)
}

func NewDefaultClient

func NewDefaultClient(srvs []sdk.Service) Client

type LoadOptionFunc

type LoadOptionFunc func(context.Context, gorp.SqlExecutor, ...*sdk.Service) error

LoadOptionFunc is used as options to load services

type MultiPartData

type MultiPartData struct {
	Reader      io.Reader
	ContentType string
}

MultiPartData represents the data to send

Directories

Path Synopsis
Package mock_services is a generated GoMock package.
Package mock_services is a generated GoMock package.

Jump to

Keyboard shortcuts

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