service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 19 Imported by: 1

Documentation

Overview

Package service defines a service that exposes a gRPC API.

The API allows external applications such as Stratumn Node's command line interface to interact with the node without having to connect to the P2P network.

The API is implemented using gRPC. It is possible to automatically generate API clients for other programming languages such as Javascript and C++.

The Protobuf types used by the API are defined in the `/grpc` folder.

For more information about gRPC, see:

https://grpc.io

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotManager is returned when the connected service is not a
	// manager.
	ErrNotManager = errors.New("connected service is not a manager")

	// ErrPeerNotFound is returned when an interceptor cannot get a peer
	// from a request.
	ErrPeerNotFound = errors.New("could not get peer")
)
View Source
var (
	RequestReceived = &view.View{
		Name:        "stratumn-node/views/grpcapi/request-received",
		Description: "grpc request received",
		Measure:     requestReceived.Measure,
		TagKeys:     []tag.Key{methodTag.OCTag},
		Aggregation: view.Count(),
	}

	RequestDuration = &view.View{
		Name:        "stratumn-node/views/grpcapi/request-duration",
		Description: "grpc request duration",
		Measure:     requestDuration.Measure,
		TagKeys:     []tag.Key{methodTag.OCTag},
		Aggregation: monitoring.DefaultLatencyDistribution,
	}

	RequestError = &view.View{
		Name:        "stratumn-node/views/grpcapi/request-error",
		Description: "grpc request error",
		Measure:     requestErr.Measure,
		TagKeys:     []tag.Key{methodTag.OCTag},
		Aggregation: view.Count(),
	}
)

Views exposed by the grpcapi app.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Manager is the name of the manager service.
	Manager string `toml:"manager" comment:"The name of the manager service."`

	// Address is the address to bind to.
	Address string `toml:"address" comment:"Address to bind to."`

	// TLSCertificateFile is a path to a TLS certificate.
	TLSCertificateFile string `toml:"tls_certificate_file" comment:"Path to a TLS certificate."`

	// TLSKeyFile is a path to a TLS key.
	TLSKeyFile string `toml:"tls_key_file" comment:"Path to a TLS key."`

	// EnableRequestLogger is whether to log unary and stream requests.
	EnableRequestLogger bool `toml:"enable_request_logger" comment:"Whether to log requests."`
}

Config contains configuration options for the gRPC API service.

type Manager

type Manager interface {
	List() []string
	Find(string) (manager.Service, error)
}

Manager represents a service manager.

type Registrable

type Registrable interface {
	AddToGRPCServer(*grpc.Server)
}

Registrable represents something that can add itself to the gRPC server, so that other services can add functions to the API.

type Service

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

Service is the gRPC API service.

func (*Service) Config

func (s *Service) Config() interface{}

Config returns the current service configuration or creates one with good default values.

func (*Service) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

func (*Service) Expose

func (s *Service) Expose() interface{}

Expose exposes the service to other services.

It exposes the type:

google.golang.org/grpc.Host

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Inform

func (s *Service) Inform(ctx context.Context, req *pb.InformReq) (*pb.Info, error)

Inform returns information about the API.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Needs

func (s *Service) Needs() map[string]struct{}

Needs returns the set of services this service depends on.

func (*Service) Plug

func (s *Service) Plug(handlers map[string]interface{}) error

Plug sets the connected services.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service handler.

Directories

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

Jump to

Keyboard shortcuts

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