Documentation ¶
Index ¶
- Variables
- func DefaultServerOptionsGRPC() []grpc.ServerOption
- func GRPCCallOK(err error) bool
- func GRPCCallSuccessful(err error) bool
- func GetLocalIPAddressString() (string, error)
- func NewRouter() chi.Router
- type Caller
- type Client
- type EndpointHTTP
- type Option
- type RoutesGetter
- type Server
- type ServiceRegistrator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilValuesIO is returned when either the input or the output are nil. ErrNilValuesIO = errors.New("nil input or output values") // ErrOutputMustBePointer is returned if the output is not a pointer. ErrOutputMustBePointer = errors.New("output must be a pointer") )
Functions ¶
func DefaultServerOptionsGRPC ¶
func DefaultServerOptionsGRPC() []grpc.ServerOption
DefaultServerOptionsGRPC is a predefined set of gRPC server options that can be used by any Server when calling the GRPC function. We encourage you to create or extend your own opts function taking this one as a starting point.
func GRPCCallOK ¶
GRPCCallOK processes a gRPC response error to verify that a gRPC call returned an OK status. The actual contents of the error are ignored. Only the call status error is checked.
func GRPCCallSuccessful ¶
GRPCCallSuccessful processes a gRPC response error to verify that a gRPC call returned an OK or Unknown status. The actual contents of the error are ignored. Only the call status error is checked.
gRPC method implementations that return anything other than a *Status value as their error value (e.g. an error generated with errors.New()) will have the value wrapped inside a *Status value and its error code set to Unknown.
This function considers calls with statuses with unknown errors successful. In addition, if the error value is not of type *Status, then the call is considered successful.
func GetLocalIPAddressString ¶
GetLocalIPAddressString returns the local IP address used by Ignition Store IP() method.
Types ¶
type Caller ¶
type Caller interface { // Call establishes a communication with the given endpoint, sending the input bytes as payload. // If there is any response, it will be returned as a slice of bytes. // Implementations should expect to receive the target service endpoint name through the `endpoint` parameter. Call(ctx context.Context, endpoint string, in []byte) ([]byte, error) }
Caller calls external service endpoints.
func NewCallerHTTP ¶
func NewCallerHTTP(baseURL *url.URL, endpoints map[string]EndpointHTTP, timeout time.Duration) Caller
NewCallerHTTP initializes a new HTTP Caller.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a generic wrapper for creating API clients with different encodings and transport layers
type EndpointHTTP ¶
type EndpointHTTP struct { // Method is the HTTP verb supported by this endpoint. Method string // Path is the relative path where this endpoint is located. // Example: /example/test Path string }
EndpointHTTP represents an HTTP endpoint.
type Option ¶
Option contains logic that can be passed to a server in its initializer to modify it.
func GRPC ¶
func GRPC(register func(s grpc.ServiceRegistrar), opts []grpc.ServerOption) Option
GRPC initializes and adds a new gRPC server to the Server. Multiple gRPC servers use the same ListenerTCP. ListenerTCP is required if this Option is passed. A set of gRPC options are passed as a function in order to inject custom middlewares to the gRPC server. DefaultServerOptionsGRPC contains a set of basic middlewares to use in any application, but we encourage you to create or extend your own opts function.
func HTTP ¶
HTTP initializes a new HTTP server to serve endpoints defined in handler on a certain port.
func ListenerTCP ¶
ListenerTCP initializes a new Listener for server. This Option is required for GRPC servers when registered in Server.
type RoutesGetter ¶
type RoutesGetter interface { // Routes returns a set of routes in a http.Handler form. Routes() http.Handler }
RoutesGetter holds a method to get routes.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a web server to listen to incoming requests. It supports different types of transport mechanisms used through Ignition Robotics projects. It currently supports HTTP and gRPC servers.
func (*Server) Close ¶
func (s *Server) Close()
Close gracefully closes all the underlying servers (HTTP & gRPC).
func (*Server) ListenAndServe ¶
ListenAndServe starts listening for incoming requests for the different HTTP and gRPC servers. Returns a channel that will receive an error from any of the current underlying transport mechanisms. Each underlying server will be launched in a different go routine.
type ServiceRegistrator ¶
type ServiceRegistrator interface { // Register registers the current service into the given server. Register(s grpc.ServiceRegistrar) }
ServiceRegistrator registers a gRPC service in a gRPC server.