server

package
v0.0.0-...-18c2e1d Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrACNotFound = errors.New("ActionResult not found or not complete")
)
View Source
var (
	ErrInvalidResourceName = errors.New("invalid resource name")
)
View Source
var (
	ErrInvalidSize = errors.New("invalid size")
)
View Source
var ServeCmd = &cobra.Command{
	Use:   "serve",
	Short: "Starts the Bazel cache gRPC server",
	RunE: func(cmd *cobra.Command, args []string) error {
		listenAddr := serveCmdFlags.listenAddr
		if serveCmdFlags.portFromEnv != "" {
			listenAddr = ":" + os.Getenv(serveCmdFlags.portFromEnv)
		}

		lis, err := net.Listen("tcp", listenAddr)
		if err != nil {
			return err
		}
		defer lis.Close()

		zap.L().With(
			zap.String("addr", lis.Addr().String()),
			zap.String("cache", serveCmdFlags.cacheURI),
		).Info("Listening")

		cc, err := cache.NewCacheFromURI(context.Background(), serveCmdFlags.cacheURI)
		if err != nil {
			return err
		}

		cs := &cacheServer{
			cache: NewCacheEx(cc),
		}

		grpcServer := grpc.NewServer(
			grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
				grpc_zap.StreamServerInterceptor(zap.L()),
			)),
			grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
				grpc_zap.UnaryServerInterceptor(zap.L()),
			)),
			grpc.ReadBufferSize(maxChunkSize),
			grpc.WriteBufferSize(maxChunkSize),
		)
		pb.RegisterActionCacheServer(grpcServer, cs)
		pb.RegisterCapabilitiesServer(grpcServer, cs)
		pb.RegisterContentAddressableStorageServer(grpcServer, cs)
		bytestream.RegisterByteStreamServer(grpcServer, cs)
		reflection.Register(grpcServer)

		return grpcServer.Serve(lis)
	},
}

Functions

This section is empty.

Types

type CacheEx

type CacheEx struct {
	cache.Cache
}

func NewCacheEx

func NewCacheEx(c cache.Cache) *CacheEx

func (*CacheEx) Contains

func (c *CacheEx) Contains(ctx context.Context, kind cache.EntryKind, digest *pb.Digest) (bool, error)

func (*CacheEx) Get

func (c *CacheEx) Get(ctx context.Context, kind cache.EntryKind, digest *pb.Digest) (io.ReadCloser, error)

func (*CacheEx) GetBytes

func (c *CacheEx) GetBytes(ctx context.Context, kind cache.EntryKind, digest *pb.Digest) ([]byte, error)

func (*CacheEx) GetProto

func (c *CacheEx) GetProto(ctx context.Context, kind cache.EntryKind, digest *pb.Digest, msg proto.Message) error

func (*CacheEx) GetRange

func (c *CacheEx) GetRange(ctx context.Context, kind cache.EntryKind, digest *pb.Digest, offset, length int64) (io.ReadCloser, error)

func (*CacheEx) Put

func (c *CacheEx) Put(ctx context.Context, kind cache.EntryKind, digest *pb.Digest) (io.WriteCloser, error)

func (*CacheEx) PutBytes

func (c *CacheEx) PutBytes(ctx context.Context, kind cache.EntryKind, digest *pb.Digest, data []byte) error

func (*CacheEx) PutProto

func (c *CacheEx) PutProto(ctx context.Context, kind cache.EntryKind, digest *pb.Digest, msg proto.Message) error

Jump to

Keyboard shortcuts

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