grpc

package
v0.1.23-oss Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxMessageSize = int(pb.ServiceConstants_MAX_CHUNK_BYTES)
)

Variables

This section is empty.

Functions

func GrpcDialHealthy

func GrpcDialHealthy(o *GrpcDialOpts) (*grpc.ClientConn, error)

GrpcDialHealthy is like grpc.Dial but returns error on an unhealthy connection

func HashToBytes

func HashToBytes(hash Hash) []byte

func HashesToHashBytes

func HashesToHashBytes(hashes []Hash) [][]byte

func HealthCheck

func HealthCheck(conn *grpc.ClientConn, service string) error

func LinkValidationToStatus

func LinkValidationToStatus(e *remote.ErrObjectLinkValidation) (*status.Status, error)

func OutputBytesFromHashes

func OutputBytesFromHashes(hashes []Hash) [][]byte

func OutputBytesFromSHA256

func OutputBytesFromSHA256(shas []SHA256) [][]byte

func ProxyDirector

func ProxyDirector(mainServiceName string, proxyPrefixToConnManager map[string]ConnectionManager) proxy.StreamDirector

ProxyDirector returns a function that is intended to be used with the "github.com/mwitkow/grpc-proxy/proxy" package. Example:

grpc.NewServer(grpc.UnknownServiceHandler(proxy.TransparentHandler(abfsgrpc.ProxyDirector(pb.ABFS_ServiceDesc.ServiceName, proxyPrefixToConnection))))

func ServerVersionMetadataInterceptor

func ServerVersionMetadataInterceptor(serviceName, clientMinVersion, serverVersion string) grpc.UnaryServerInterceptor

ServerVersionMetadataInterceptor is meant to be used with grpc.UnaryInterceptor. Example:

grpc.NewServer(
 grpc.UnaryInterceptor(abfsgrpc.ServerVersionMetadataInterceptor(pb.ARES_ServiceDesc.ServiceName)),
)

func ServerVersionMetadataStreamInterceptor

func ServerVersionMetadataStreamInterceptor(serviceName, clientMinVersion, serverVersion string) grpc.StreamServerInterceptor

ServerVersionMetadataStreamInterceptor is meant to be used with grpc.StreamInterceptor. Example:

grpc.NewServer(
 grpc.StreamInterceptor(abfsgrpc.ServerVersionMetadataStreamInterceptor(pb.ARES_ServiceDesc.ServiceName)),
)

func UnwrapMissingLinkError

func UnwrapMissingLinkError(err error) error

UnwrapMissingLinkError looks for a grpc status error that has any ObjectLink details and unwraps it into a native Go error if found.

func WrapErrorInStatus

func WrapErrorInStatus(err error) error

WrapErrorInStatus looks for specific typed errors (like ErrObjectLinkValidation or ErrPermissionDenied) and wraps them in a grpc Status error if found.

Types

type ByteCounter

type ByteCounter struct {
	// contains filtered or unexported fields
}

func (*ByteCounter) HandleConn

func (b *ByteCounter) HandleConn(ctx context.Context, s stats.ConnStats)

func (*ByteCounter) HandleRPC

func (b *ByteCounter) HandleRPC(ctx context.Context, s stats.RPCStats)

func (*ByteCounter) TagConn

func (b *ByteCounter) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context

func (*ByteCounter) TagRPC

func (b *ByteCounter) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context

type BytesStatHandler

type BytesStatHandler interface {
	AddBytesSent(int64)
	AddBytesReceived(int64)
}

type Chunker

type Chunker interface {
	GetChunk() *pb.Chunk
}

type ConnectionManager

type ConnectionManager interface {
	Select() (*grpc.ClientConn, error)
}

type GrpcDialOpts

type GrpcDialOpts struct {
	ServiceName      string
	Address          string
	BytesStatHandler BytesStatHandler
	ClientVersion    string
	ServerMinVersion string
	TokenSource      auth.TokenSource
	RootCAFile       string
	RetryPolicy      string
	DisableTLS       bool
	SkipHealthCheck  bool
}

GrpcDialOpts contains the options for GrpcDialHealthy.

type Hash

type Hash = entities.Hash

func HashBytesToHashes

func HashBytesToHashes(bytes [][]byte) []Hash

func HashFromInputBytes

func HashFromInputBytes(input []byte) (hash Hash)

func HashesFromInputBytes

func HashesFromInputBytes(input [][]byte) []Hash

type PBClient

type PBClient struct {
	// contains filtered or unexported fields
}

func NewPBClient

func NewPBClient(pb pb.ABFSClient) *PBClient

func (*PBClient) AddMapResult

func (c *PBClient) AddMapResult(ctx context.Context, from remote.Hash, to remote.Hash) error

AddMapResult implements remote.RemoteProvider.

func (*PBClient) GetObject

func (c *PBClient) GetObject(ctx context.Context, key remote.Hash) (remote.ContentReadCloser, error)

GetObject implements remote.RemoteProvider.

func (*PBClient) GetRefs

func (c *PBClient) GetRefs(ctx context.Context, server string, project string, refs []string) ([]remote.Hash, error)

GetRefs implements remote.RemoteProvider.

func (*PBClient) Headers

func (c *PBClient) Headers(ctx context.Context, keys []remote.Hash) ([]entities.ObjectHeader, error)

Headers implements remote.RemoteProvider.

func (*PBClient) MapResults

func (c *PBClient) MapResults(ctx context.Context, from remote.Hash) ([]remote.Hash, error)

MapResults implements remote.RemoteProvider.

func (*PBClient) Mark

func (c *PBClient) Mark(ctx context.Context, hash remote.Hash, key string, value string) (int64, error)

Mark implements remote.RemoteProvider.

func (*PBClient) PutObject

func (c *PBClient) PutObject(ctx context.Context, key remote.Hash, reader remote.ContentReadCloser) error

PutObject implements remote.RemoteProvider.

func (*PBClient) PutRefs

func (c *PBClient) PutRefs(ctx context.Context, server string, project string, refs []remote.RefHash) error

PutRefs implements remote.RemoteProvider.

func (*PBClient) SHA256

func (c *PBClient) SHA256(ctx context.Context, keys []remote.Hash) ([]entities.SHA256, error)

SHA256 implements remote.RemoteProvider.

func (*PBClient) SearchRefs

func (c *PBClient) SearchRefs(ctx context.Context, server string, project string, refPrefix string, limit int) ([]remote.ProjectRefHash, error)

SearchRefs implements remote.RemoteProvider.

func (*PBClient) Version

func (c *PBClient) Version(ctx context.Context) (string, error)

Version implements remote.RemoteProvider.

func (*PBClient) WhoAmI

func (c *PBClient) WhoAmI(ctx context.Context) (string, error)

WhoAmI implements remote.RemoteProvider.

type PBServer

type PBServer struct {
	pb.UnimplementedABFSServer
	// contains filtered or unexported fields
}

func NewPBServer

func NewPBServer(server remote.RemoteProvider) *PBServer

func (*PBServer) AddMapResult

func (s *PBServer) AddMapResult(ctx context.Context, req *pb.AddMapResultRequest) (*pb.AddMapResultReply, error)

AddMapResult implements ABFSServer.

func (*PBServer) GetObject

func (s *PBServer) GetObject(req *pb.GetObjectRequest, stream pb.ABFS_GetObjectServer) (retErr error)

GetObject implements ABFSServer.

func (*PBServer) GetRefs

func (s *PBServer) GetRefs(ctx context.Context, req *pb.GetRefsRequest) (*pb.GetRefsReply, error)

GetRefs implements ABFSServer.

func (*PBServer) GetVersion

func (s *PBServer) GetVersion(ctx context.Context, req *pb.GetVersionRequest) (*pb.GetVersionReply, error)

GetVersion implements ABFSServer.

func (*PBServer) Headers

func (s *PBServer) Headers(ctx context.Context, req *pb.HeadersRequest) (*pb.HeadersReply, error)

Headers implements ABFSServer.

func (*PBServer) MapResults

func (s *PBServer) MapResults(ctx context.Context, req *pb.MapResultsRequest) (*pb.MapResultsReply, error)

MapResults implements ABFSServer.

func (*PBServer) PutObject

func (s *PBServer) PutObject(stream pb.ABFS_PutObjectServer) error

PutObject implements ABFSServer.

func (*PBServer) PutRefs

func (s *PBServer) PutRefs(ctx context.Context, req *pb.PutRefsRequest) (*pb.PutRefsReply, error)

PutRefs implements ABFSServer.

func (*PBServer) SHA256

func (s *PBServer) SHA256(ctx context.Context, req *pb.SHA256Request) (*pb.SHA256Reply, error)

SHA256 implements ABFSServer.

func (*PBServer) SearchRefs

func (s *PBServer) SearchRefs(ctx context.Context, req *pb.SearchRefsRequest) (*pb.SearchRefsReply, error)

SearchRefs implements ABFSServer.

func (*PBServer) WhoAmI

func (s *PBServer) WhoAmI(ctx context.Context, req *pb.WhoAmIRequest) (*pb.WhoAmIReply, error)

WhoAmI implements ABFSServer. This call does not get delegated to the s.server RemoteProvider because it is not a function of the backing store. One implementation can be used.

type RandomConnectionManager

type RandomConnectionManager struct {
	// contains filtered or unexported fields
}

func NewRandomConnectionManager

func NewRandomConnectionManager(conns []*grpc.ClientConn) *RandomConnectionManager

NewRandomConnectionManager creates a new connection manager that selects a connection randomly.

func (*RandomConnectionManager) Add

func (m *RandomConnectionManager) Add(conn *grpc.ClientConn)

Add adds a new connection to the manager.

func (*RandomConnectionManager) Remove

func (m *RandomConnectionManager) Remove(conn *grpc.ClientConn)

Remove removes a connection from the manager.

func (*RandomConnectionManager) Select

func (m *RandomConnectionManager) Select() (*grpc.ClientConn, error)

type SHA256

type SHA256 = entities.SHA256

func SHA256BytesToSHA256

func SHA256BytesToSHA256(bytes [][]byte) []SHA256

type Stream

type Stream interface {
	Context() context.Context
	SendMsg(m any) error
	RecvMsg(m any) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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