grpcutil

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCredentials notifies that the provided credentials are invalid or missing.
	ErrInvalidCredentials = status.Error(codes.Unauthenticated, "invalid credentials")
	// ErrTokenMissing notifies that the bearer token could not be found.
	ErrTokenMissing = status.Error(codes.Unauthenticated, "token missing")
	// ErrNotActive notifies that the user is not active.
	ErrNotActive = status.Error(codes.PermissionDenied, "user is not active")
	// ErrPermissionDenied notifies that the user does not have permission to access the method.
	ErrPermissionDenied = status.Error(codes.PermissionDenied, "user does not have permission")
)

OrderBySQL maps our protobuf OrderBy enum to SQL. Unspecified maps to ASC.

View Source
var UnimplementedError = status.Error(codes.Unimplemented, "method not yet available")

UnimplementedError is the error return by API endpoints that are not yet implemented.

Functions

func ConnectionIsClosed

func ConnectionIsClosed(stream grpc.ServerStream) bool

ConnectionIsClosed returns whether the connection has been closed from the client's side.

func GetUser

func GetUser(ctx context.Context) (*model.User, *model.UserSession, error)

GetUser returns the currently logged in user.

func GetUserExternalToken

func GetUserExternalToken(ctx context.Context) (string, error)

GetUserExternalToken returns the external token for the currently logged in user.

func NewGRPCServer

func NewGRPCServer(db *db.PgDB, srv proto.DeterminedServer, enablePrometheus bool,
	extConfig *model.ExternalSessions, logStore *logger.LogBuffer,
) *grpc.Server

NewGRPCServer creates a Determined gRPC service.

func RegisterHTTPProxy

func RegisterHTTPProxy(ctx context.Context, e *echo.Echo, port int, cert *tls.Certificate) error

RegisterHTTPProxy registers grpc-gateway with the master echo server.

func ValidateRequest

func ValidateRequest(checks ...Check) error

ValidateRequest validates that all the checks pass. If a check does not pass, an InvalidArgument error is returned.

Types

type Check

type Check func() (bool, string)

Check returns a bool value denoting whether the check passed or failed. If the check fails, the string denotes the error reason.

func ValidateFollow

func ValidateFollow(limit int32, follow bool) Check

ValidateFollow validates Follow message fields.

func ValidateLimit

func ValidateLimit(limit int32) Check

ValidateLimit validates Limit message fields.

Jump to

Keyboard shortcuts

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