protoregistry

package
v1.87.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpUnknown = unknown operation type
	OpUnknown = iota
	// OpAccessor = accessor operation type (ready only)
	OpAccessor
	// OpMutator = mutator operation type (modifies a repository)
	OpMutator
)
View Source
const (
	// ScopeUnknown is the default scope until determined otherwise
	ScopeUnknown = iota
	// ScopeRepository indicates an RPC's scope is limited to a repository
	ScopeRepository = iota
	// ScopeStorage indicates an RPC is scoped to an entire storage location
	ScopeStorage
	// ScopeServer indicates an RPC is scoped to an entire server
	ScopeServer
)

Variables

View Source
var ErrTargetRepoMissing = errors.New("empty Repository")

ErrTargetRepoMissing indicates that the target repo is missing or not set

Functions

func ExtractFileDescriptor added in v1.55.0

func ExtractFileDescriptor(gz []byte) (*descriptor.FileDescriptorProto, error)

ExtractFileDescriptor extracts a FileDescriptorProto from a gzip'd buffer. https://github.com/golang/protobuf/blob/9eb2c01ac278a5d89ce4b2be68fe4500955d8179/descriptor/descriptor.go#L50

Types

type MethodInfo

type MethodInfo struct {
	Operation OpType
	Scope     Scope
	// contains filtered or unexported fields
}

MethodInfo contains metadata about the RPC method. Refer to documentation for message type "OperationMsg" shared.proto in ./proto for more documentation.

func (MethodInfo) AdditionalRepo added in v1.69.0

func (mi MethodInfo) AdditionalRepo(msg proto.Message) (*gitalypb.Repository, bool, error)

AdditionalRepo returns the additional repository for a protobuf message that needs a storage rewritten if it exists

func (MethodInfo) Storage added in v1.73.0

func (mi MethodInfo) Storage(msg proto.Message) (string, error)

Storage returns the storage name for a protobuf message if it exists

func (MethodInfo) TargetRepo added in v1.43.0

func (mi MethodInfo) TargetRepo(msg proto.Message) (*gitalypb.Repository, error)

TargetRepo returns the target repository for a protobuf message if it exists

func (MethodInfo) UnmarshalRequestProto added in v1.56.0

func (mi MethodInfo) UnmarshalRequestProto(b []byte) (proto.Message, error)

UnmarshalRequestProto will unmarshal the bytes into the method's request message type

type OpType

type OpType int

OpType represents the operation type for a RPC method

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry contains info about RPC methods

var (
	// GitalyProtoFileDescriptors is a slice of all gitaly registered file
	// descriptors
	GitalyProtoFileDescriptors []*descriptor.FileDescriptorProto
	// GitalyProtoPreregistered is a proto registry pre-registered with all
	// GitalyProtoFileDescriptors file descriptor protos
	GitalyProtoPreregistered *Registry
)

GitalyProtoFileDescriptors is a slice of all gitaly registered file descriptors

func New

func New() *Registry

New creates a new ProtoRegistry

func (*Registry) LookupMethod

func (pr *Registry) LookupMethod(fullMethodName string) (MethodInfo, error)

LookupMethod looks up an MethodInfo by service and method name

func (*Registry) RegisterFiles

func (pr *Registry) RegisterFiles(protos ...*descriptor.FileDescriptorProto) error

RegisterFiles takes one or more descriptor.FileDescriptorProto and populates the registry with its info

type Scope added in v1.57.0

type Scope int

Scope represents the intended scope of an RPC method

Jump to

Keyboard shortcuts

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