Documentation ¶
Index ¶
- Variables
- func ByteSliceHasAnyPrefix(s []byte, prefixes ...string) bool
- func DecorateError(code codes.Code, err error) error
- func ErrInternal(err error) error
- func ErrInternalf(format string, a ...interface{}) error
- func ErrInvalidArgument(err error) error
- func ErrInvalidArgumentf(format string, a ...interface{}) error
- func ErrNotFound(err error) error
- func ErrPreconditionFailed(err error) error
- func ErrPreconditionFailedf(format string, a ...interface{}) error
- func ExtractGitalyServer(ctx context.Context, storageName string) (storage.ServerInfo, error)
- func ExtractGitalyServers(ctx context.Context) (gitalyServersInfo storage.GitalyServers, err error)
- func GrpcCode(err error) codes.Code
- func IncomingToOutgoing(ctx context.Context) context.Context
- func InjectGitalyServers(ctx context.Context, name, address, token string) (context.Context, error)
- func IsNumber(s []byte) bool
- func OutgoingToIncoming(ctx context.Context) context.Context
- func RepoPathEqual(a, b repository.GitRepo) bool
- func SanitizeError(err error) error
- func SanitizeString(str string) string
- func SuppressCancellation(ctx context.Context) context.Context
- func UnquoteBytes(s []byte) []byte
- type ManualTicker
- type Ticker
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyMetadata = errors.New("empty metadata")
ErrEmptyMetadata indicates that the gRPC metadata was not found in the context
var MaxCommitOrTagMessageSize = 10 * 1024
MaxCommitOrTagMessageSize is the threshold for a commit/tag message, if exceeded then message is truncated and it's up to the client to request it in full separately.
Functions ¶
func ByteSliceHasAnyPrefix ¶
ByteSliceHasAnyPrefix tests whether the byte slice s begins with any of the prefixes.
func DecorateError ¶
DecorateError unless it's already a grpc error.
If given nil it will return nil.
func ErrInternal ¶
ErrInternal wraps err with codes.Internal, unless err is already a grpc error
func ErrInternalf ¶
ErrInternalf wrapps a formatted error with codes.Internal, clobbering any existing grpc error
func ErrInvalidArgument ¶
ErrInvalidArgument wraps err with codes.InvalidArgument, unless err is already a grpc error
func ErrInvalidArgumentf ¶
ErrInvalidArgumentf wraps a formatted error with codes.InvalidArgument, clobbering any existing grpc error
func ErrNotFound ¶
ErrNotFound wraps error with codes.NotFound, unless err is already a grpc error
func ErrPreconditionFailed ¶
ErrPreconditionFailed wraps err with codes.FailedPrecondition, unless err is already a grpc error
func ErrPreconditionFailedf ¶
ErrPreconditionFailedf wraps a formatted error with codes.FailedPrecondition, clobbering any existing grpc error
func ExtractGitalyServer ¶
ExtractGitalyServer extracts server information for a specific storage
func ExtractGitalyServers ¶
func ExtractGitalyServers(ctx context.Context) (gitalyServersInfo storage.GitalyServers, err error)
ExtractGitalyServers extracts `storage.GitalyServers` from an incoming context.
func GrpcCode ¶
GrpcCode emulates the old grpc.Code function: it translates errors into codes.Code values.
func IncomingToOutgoing ¶
IncomingToOutgoing creates an outgoing context out of an incoming context with the same storage metadata
func InjectGitalyServers ¶
InjectGitalyServers injects gitaly-servers metadata into an outgoing context
func OutgoingToIncoming ¶
OutgoingToIncoming creates an incoming context out of an outgoing context with the same storage metadata
func RepoPathEqual ¶
func RepoPathEqual(a, b repository.GitRepo) bool
RepoPathEqual compares if two repositories are in the same location
func SanitizeError ¶
SanitizeError does the same thing as SanitizeString but for error types
func SanitizeString ¶
SanitizeString will clean password and tokens from URLs, and replace them with [FILTERED].
func SuppressCancellation ¶
SuppressCancellation returns a context that suppresses cancellation or expiration of the parent context.
func UnquoteBytes ¶
UnquoteBytes removes surrounding double-quotes from a byte slice returning a new slice if they exist, otherwise it returns the same byte slice passed.
Types ¶
type ManualTicker ¶
type ManualTicker struct { StopFunc func() ResetFunc func() // contains filtered or unexported fields }
ManualTicker implements a ticker that ticks when Tick is called. Stop and Reset functions call the provided functions.
func NewCountTicker ¶
func NewCountTicker(n int, callback func()) *ManualTicker
NewCountTicker returns a ManualTicker with a ResetFunc that calls the provided callback on Reset call after it has been called N times.
func NewManualTicker ¶
func NewManualTicker() *ManualTicker
NewManualTicker returns a Ticker that can be manually controlled.
func (*ManualTicker) C ¶
func (mt *ManualTicker) C() <-chan time.Time
func (*ManualTicker) Reset ¶
func (mt *ManualTicker) Reset()
func (*ManualTicker) Stop ¶
func (mt *ManualTicker) Stop()
func (*ManualTicker) Tick ¶
func (mt *ManualTicker) Tick()
type Ticker ¶
Ticker ticks on the channel returned by C to signal something.
func NewTimerTicker ¶
NewTimerTicker returns a Ticker that ticks after the specified interval has passed since the previous Reset call.