Documentation ¶
Index ¶
- Constants
- func AppendMessageSizeToOutgoingContext(ctx context.Context, req Sizer) context.Context
- func ErrorToStatus(err error) (*status.Status, bool)
- func ErrorToStatusCode(err error) codes.Code
- func IsCanceled(err error) bool
- type Check
- type HealthCheck
- type Operation
- type Resolver
- type Sizer
- type Update
- type Watcher
Constants ¶
const MetadataMessageSize = "message-size"
MetadataMessageSize is grpc metadata key for message size.
Variables ¶
This section is empty.
Functions ¶
func ErrorToStatus ¶
ErrorToStatus returns a *github.com/gogo/status.Status representation of err.
If err implements the method `GRPCStatus() *google.golang.org/grpc/status.Status` and `GRPCStatus()` does not return nil, or if err wraps a type satisfying this, Status from `GRPCStatus()` is converted to gogo Status, and returned. In that case, ok is true.
If err is or GRPCStatus() returns nil, a nil Status is returned and ok is false.
Otherwise, err is an error not compatible with this function. In this case, a nil Status is returned and ok is false.
func ErrorToStatusCode ¶
ErrorToStatusCode extracts gRPC status code from error and returns it.
If err is nil, codes.OK is returned.
If err implements (or wraps error that implements) the method `GRPCStatus() *google.golang.org/grpc/status.Status`, and `GRPCStatus()` returns a non-nil status, code from the status is returned.
Otherwise code.Unknown is returned.
func IsCanceled ¶
IsCanceled checks whether an error comes from an operation being canceled.
Types ¶
type Check ¶
Check is a function that determines if this gRPC application is healthy.
func WithManager ¶
WithManager returns a new Check that tests if the managed services are healthy.
func WithShutdownRequested ¶
WithShutdownRequested returns a new Check that returns false when shutting down.
type HealthCheck ¶
type HealthCheck struct {
// contains filtered or unexported fields
}
HealthCheck fulfills the grpc_health_v1.HealthServer interface by ensuring each of the provided Checks indicates the application is healthy.
func NewHealthCheck ¶
func NewHealthCheck(sm *services.Manager) *HealthCheck
NewHealthCheck returns a new HealthCheck for the provided service manager.
func NewHealthCheckFrom ¶
func NewHealthCheckFrom(checks ...Check) *HealthCheck
NewHealthCheckFrom returns a new HealthCheck that uses each of the provided Checks.
func (*HealthCheck) Check ¶
func (h *HealthCheck) Check(ctx context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check implements the grpc healthcheck.
func (*HealthCheck) Watch ¶
func (h *HealthCheck) Watch(_ *grpc_health_v1.HealthCheckRequest, _ grpc_health_v1.Health_WatchServer) error
Watch implements the grpc healthcheck.
type Operation ¶
type Operation uint8
Operation defines the corresponding operations for a name resolution change.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver handles name resolution for names following the DNS scheme.
func NewDNSResolver ¶
NewDNSResolver creates a DNS Resolver that can resolve DNS names, and create watchers that poll the DNS server using the default frequency defined by defaultFreq.
func NewDNSResolverWithFreq ¶
NewDNSResolverWithFreq creates a DNS Resolver that can resolve DNS names, and create watchers that poll the DNS server using the frequency set by freq.
func (*Resolver) Resolve ¶
Resolve creates a watcher that watches the SRV/hostname record resolution of the target.
If service is not empty, the watcher will first attempt to resolve an SRV record. If that fails, or service is empty, hostname record resolution is attempted instead. If target can be parsed as an IP address, the watcher will return it, and will not send any more updates afterwards.
type Update ¶
type Update struct { // Op indicates the operation of the update. Op Operation // Addr is the updated address. It is empty string if there is no address update. Addr string // Metadata is the updated metadata. It is nil if there is no metadata update. // Metadata is not required for a custom naming implementation. Metadata interface{} }
Update defines a name resolution update. Notice that it is not valid having both empty string Addr and nil Metadata in an Update.
type Watcher ¶
type Watcher interface { // Next blocks until an update or error happens. It may return one or more // updates. The first call should get the full set of the results. It should // return an error if and only if Watcher cannot recover. Next() ([]*Update, error) // Close closes the Watcher. Close() }
Watcher watches for SRV updates on the specified target.