api

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT, Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseError                     = -31700
	ParseErrorShort                = "ParseError"
	ParseErrorMessage              = "Parsing error on the server side: received an invalid JSON."
	InvalidRequestError            = -31600
	InvalidRequestErrorShort       = "InvalidRequest"
	InvalidRequestErrorMessage     = "The JSON received is not a valid request payload."
	MethodNotFoundError            = -31601
	MethodNotFoundErrorShort       = "MethodNotFound"
	MethodNotFoundErrorMessage     = "Method does not exist / is not available."
	InvalidParamsError             = -31602
	InvalidParamsErrorShort        = "InvalidParams"
	InvalidParamsErrorMessage      = "Invalid method parameter(s)."
	InternalError                  = -31603
	InternalErrorShort             = "Internal"
	InternalErrorMessage           = "Internal Platform error."
	TimeoutError                   = -31106
	TimeoutErrorShort              = "Timeout"
	TimeoutErrorMessage            = "Request's timeout has expired."
	UnauthorizedError              = -31401
	UnauthorizedErrorShort         = "Unauthorized"
	UnauthorizedErrorMessage       = "Action is not authorized."
	ExecutionError                 = -31103
	ExecutionErrorShort            = "Execution"
	ExecutionErrorMessage          = "Execution error."
	ServiceUnavailableError        = -31429
	ServiceUnavailableErrorShort   = "ServiceUnavailable"
	ServiceUnavailableErrorMessage = "Service unavailable, try again later."
)

Variables

This section is empty.

Functions

func IsInternalMethod

func IsInternalMethod(method string) bool

Types

type APIRunner

type APIRunner interface {
	IsAPIRunner() bool
}

nolint

type AvailabilityChecker

type AvailabilityChecker interface {
	IsAvailable(context.Context) bool
}

AvailabilityChecker component checks if insolar network can't process any new requests

type AvailabilityCheckerMock

type AvailabilityCheckerMock struct {
	IsAvailableMock mAvailabilityCheckerMockIsAvailable
	// contains filtered or unexported fields
}

AvailabilityCheckerMock implements AvailabilityChecker

func NewAvailabilityCheckerMock

func NewAvailabilityCheckerMock(t minimock.Tester) *AvailabilityCheckerMock

NewAvailabilityCheckerMock returns a mock for AvailabilityChecker

func (*AvailabilityCheckerMock) IsAvailable

func (mmIsAvailable *AvailabilityCheckerMock) IsAvailable(ctx context.Context) (b1 bool)

IsAvailable implements AvailabilityChecker

func (*AvailabilityCheckerMock) IsAvailableAfterCounter

func (mmIsAvailable *AvailabilityCheckerMock) IsAvailableAfterCounter() uint64

IsAvailableAfterCounter returns a count of finished AvailabilityCheckerMock.IsAvailable invocations

func (*AvailabilityCheckerMock) IsAvailableBeforeCounter

func (mmIsAvailable *AvailabilityCheckerMock) IsAvailableBeforeCounter() uint64

IsAvailableBeforeCounter returns a count of AvailabilityCheckerMock.IsAvailable invocations

func (*AvailabilityCheckerMock) MinimockFinish

func (m *AvailabilityCheckerMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*AvailabilityCheckerMock) MinimockIsAvailableDone

func (m *AvailabilityCheckerMock) MinimockIsAvailableDone() bool

MinimockIsAvailableDone returns true if the count of the IsAvailable invocations corresponds the number of defined expectations

func (*AvailabilityCheckerMock) MinimockIsAvailableInspect

func (m *AvailabilityCheckerMock) MinimockIsAvailableInspect()

MinimockIsAvailableInspect logs each unmet expectation

func (*AvailabilityCheckerMock) MinimockWait

func (m *AvailabilityCheckerMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

type AvailabilityCheckerMockIsAvailableExpectation

type AvailabilityCheckerMockIsAvailableExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

AvailabilityCheckerMockIsAvailableExpectation specifies expectation struct of the AvailabilityChecker.IsAvailable

func (*AvailabilityCheckerMockIsAvailableExpectation) Then

Then sets up AvailabilityChecker.IsAvailable return parameters for the expectation previously defined by the When method

type AvailabilityCheckerMockIsAvailableParams

type AvailabilityCheckerMockIsAvailableParams struct {
	// contains filtered or unexported fields
}

AvailabilityCheckerMockIsAvailableParams contains parameters of the AvailabilityChecker.IsAvailable

type AvailabilityCheckerMockIsAvailableResults

type AvailabilityCheckerMockIsAvailableResults struct {
	// contains filtered or unexported fields
}

AvailabilityCheckerMockIsAvailableResults contains results of the AvailabilityChecker.IsAvailable

type DummyNetworkChecker

type DummyNetworkChecker struct{}

func (DummyNetworkChecker) IsAvailable

func (d DummyNetworkChecker) IsAvailable(ctx context.Context) bool

type HealthChecker

type HealthChecker struct {
	CertificateManager nodeinfo.CertificateManager
	NodeNetwork        beat.NodeNetwork
}

HealthChecker allows to check network status of a node.

func NewHealthChecker

func NewHealthChecker(cm nodeinfo.CertificateManager, nn beat.NodeNetwork) *HealthChecker

NewHealthChecker creates new HealthChecker.

func (*HealthChecker) CheckHandler

func (hc *HealthChecker) CheckHandler(w http.ResponseWriter, r *http.Request)

CheckHandler is a HTTP handler for health check.

type NetworkChecker

type NetworkChecker struct {
	// contains filtered or unexported fields
}

NetworkChecker is AvailabilityChecker implementation that checks can we process any API requests based on keeper status

func (*NetworkChecker) IsAvailable

func (nc *NetworkChecker) IsAvailable(ctx context.Context) bool

func (*NetworkChecker) Start

func (nc *NetworkChecker) Start(ctx context.Context) error

func (*NetworkChecker) Stop

func (nc *NetworkChecker) Stop()

func (*NetworkChecker) UpdateAvailability

func (nc *NetworkChecker) UpdateAvailability(ctx context.Context)

type NodeService

type NodeService struct {
	// contains filtered or unexported fields
}

NodeService is a service that provides API for getting new seed and status.

func NewNodeService

func NewNodeService(runner *Runner) *NodeService

NewNodeService creates new Node service instance.

func (*NodeService) GetSeed

func (s *NodeService) GetSeed(r *http.Request, args *SeedArgs, _ *rpc.RequestBody, reply *requester.SeedReply) error

func (*NodeService) GetStatus

func (s *NodeService) GetStatus(r *http.Request, args *interface{}, requestBody *rpc.RequestBody, reply *requester.StatusResponse) error

Get returns status info

type RequestValidator

type RequestValidator struct {
	// contains filtered or unexported fields
}

func NewRequestValidator

func NewRequestValidator(path string, next http.Handler) (*RequestValidator, error)

func (*RequestValidator) ServeHTTP

func (rv *RequestValidator) ServeHTTP(w http.ResponseWriter, httpReq *http.Request)

func (*RequestValidator) Validate

func (rv *RequestValidator) Validate(ctx context.Context, httpReq *http.Request) error

type Runner

type Runner struct {
	CertificateManager nodeinfo.CertificateManager
	// nolint
	NodeNetwork         beat.NodeNetwork
	CertificateGetter   nodeinfo.CertificateGetter
	PulseAccessor       beat.History
	JetCoordinator      affinity.Helper
	NetworkStatus       network.Status
	AvailabilityChecker AvailabilityChecker

	SeedManager   *seedmanager.SeedManager
	SeedGenerator seedmanager.SeedGenerator
	// contains filtered or unexported fields
}

Runner implements Component for API

func NewRunner

func NewRunner(cfg *configuration.APIRunner,
	logger log.Logger,
	certificateManager nodeinfo.CertificateManager,

	nodeNetwork beat.NodeNetwork,
	certificateGetter nodeinfo.CertificateGetter,
	pulseAccessor beat.History,
	jetCoordinator affinity.Helper,
	networkStatus network.Status,
	availabilityChecker AvailabilityChecker,
) (*Runner, error)

NewRunner is C-tor for API Runner

func (*Runner) Handler

func (ar *Runner) Handler() http.Handler

Handler returns root http handler.

func (*Runner) IsAPIRunner

func (ar *Runner) IsAPIRunner() bool

IsAPIRunner is implementation of APIRunner interface for component manager

func (*Runner) Start

func (ar *Runner) Start(ctx context.Context) error

Start runs api server

func (*Runner) Stop

func (ar *Runner) Stop(ctx context.Context) error

Stop stops api server

type RunnerWrapper

type RunnerWrapper struct {
	API      APIRunner
	AdminAPI APIRunner
}

func NewWrapper

func NewWrapper(publicAPI, adminAPI APIRunner) *RunnerWrapper

NewWrapper is C-tor for wrapper of API Runner

func (*RunnerWrapper) Start

func (w *RunnerWrapper) Start(ctx context.Context) error

Start runs api servers

func (*RunnerWrapper) Stop

func (w *RunnerWrapper) Stop(ctx context.Context) error

Start stops api servers

type SeedArgs

type SeedArgs struct{}

SeedArgs is arguments that Seed service accepts.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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