remotesrv

package
v0.40.5-0...-26e1d5b Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const RepoPathField = "repo_path"

Variables

View Source
var CLONE_ADMIN_RPC_METHODS = map[string]bool{
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/GetDownloadLocations":    true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/GetRepoMetadata":         true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/HasChunks":               true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/ListTableFiles":          true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/RefreshTableFileUrl":     true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/Root":                    true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/StreamDownloadLocations": true,
}
View Source
var (
	ErrReadOutOfBounds = errors.New("cannot read file for given length and " +
		"offset since the read would exceed the size of the file")
)
View Source
var ErrUnimplemented = errors.New("unimplemented")
View Source
var SUPER_USER_RPC_METHODS = map[string]bool{
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/AddTableFiles":      true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/Commit":             true,
	"/dolt.services.remotesapi.v1alpha1.ChunkStoreService/GetUploadLocations": true,
}

Functions

func ValidateAddTableFilesRequest

func ValidateAddTableFilesRequest(req *remotesapi.AddTableFilesRequest) error

func ValidateCommitRequest

func ValidateCommitRequest(req *remotesapi.CommitRequest) error

func ValidateGetDownloadLocsRequest

func ValidateGetDownloadLocsRequest(req *remotesapi.GetDownloadLocsRequest) error

func ValidateGetRepoMetadataRequest

func ValidateGetRepoMetadataRequest(req *remotesapi.GetRepoMetadataRequest) error

func ValidateGetUploadLocsRequest

func ValidateGetUploadLocsRequest(req *remotesapi.GetUploadLocsRequest) error

func ValidateHasChunksRequest

func ValidateHasChunksRequest(req *remotesapi.HasChunksRequest) error

func ValidateListTableFilesRequest

func ValidateListTableFilesRequest(req *remotesapi.ListTableFilesRequest) error

func ValidateRebaseRequest

func ValidateRebaseRequest(req *remotesapi.RebaseRequest) error

func ValidateRefreshTableFileUrlRequest

func ValidateRefreshTableFileUrlRequest(req *remotesapi.RefreshTableFileUrlRequest) error

func ValidateRootRequest

func ValidateRootRequest(req *remotesapi.RootRequest) error

Types

type AccessControl

type AccessControl interface {
	// ApiAuthenticate checks the incoming request for authentication credentials and validates them. If the user's
	// identity checks out, the returned context will have the sqlContext within it, which contains the user's ID.
	// If the user is not legitimate, an error is returned.
	ApiAuthenticate(ctx context.Context) (context.Context, error)
	// ApiAuthorize checks that the authenticated user has sufficient privileges to perform the requested action.
	// Currently, our resource policy is binary currently, a user either is a SuperUser (form Commit) or they have a
	// CLONE_ADMIN grant for read operations.
	// More resource aware authorization decisions will be needed in the future, but this is sufficient for now.
	ApiAuthorize(ctx context.Context, superUserReq bool) (bool, error)
}

AccessControl is an interface that provides authentication and authorization for the gRPC server.

type DBCache

type DBCache interface {
	Get(ctx context.Context, path, nbfVerStr string) (RemoteSrvStore, error)
}

type Listeners

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

func (Listeners) Close

func (l Listeners) Close() error

type ReadOnlyChunkStore

type ReadOnlyChunkStore struct {
	remotesapi.ChunkStoreServiceServer
}

func (ReadOnlyChunkStore) AddTableFiles

func (ReadOnlyChunkStore) Commit

func (ReadOnlyChunkStore) GetUploadLocations

type RemoteChunkStore

type RemoteChunkStore struct {
	HttpHost string

	remotesapi.UnimplementedChunkStoreServiceServer
	// contains filtered or unexported fields
}

func NewHttpFSBackedChunkStore

func NewHttpFSBackedChunkStore(lgr *logrus.Entry, httpHost string, csCache DBCache, fs filesys.Filesys, scheme string, concurrencyControl remotesapi.PushConcurrencyControl, sealer Sealer) *RemoteChunkStore

func (*RemoteChunkStore) AddTableFiles

AddTableFiles updates the remote manifest with new table files without modifying the root hash.

func (*RemoteChunkStore) Commit

func (*RemoteChunkStore) GetDownloadLocations

func (*RemoteChunkStore) GetRepoMetadata

func (*RemoteChunkStore) GetUploadLocations

func (*RemoteChunkStore) HasChunks

func (*RemoteChunkStore) ListTableFiles

func (*RemoteChunkStore) Rebase

func (*RemoteChunkStore) Root

func (*RemoteChunkStore) StreamDownloadLocations

type RemoteSrvStore

type RemoteSrvStore interface {
	chunks.ChunkStore
	chunks.TableFileStore

	Path() (string, bool)
	GetChunkLocationsWithPaths(hashes hash.HashSet) (map[string]map[hash.Hash]nbs.Range, error)
}

type RequestCredentials

type RequestCredentials struct {
	Username string
	Password string
	Address  string
}

func ExtractBasicAuthCreds

func ExtractBasicAuthCreds(ctx context.Context) (*RequestCredentials, error)

ExtractBasicAuthCreds extracts the username and password from the incoming request. It returns RequestCredentials populated with necessary information to authenticate the request. nil and an error will be returned if any error occurs.

type Sealer

type Sealer interface {
	Seal(*url.URL) (*url.URL, error)
	Unseal(*url.URL) (*url.URL, error)
}

Interface to seal requests to the HTTP server so that they cannot be forged. The gRPC server seals URLs and the HTTP server unseals them.

func NewSingleSymmetricKeySealer

func NewSingleSymmetricKeySealer() (Sealer, error)

type Server

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

func NewServer

func NewServer(args ServerArgs) (*Server, error)

func (*Server) GracefulStop

func (s *Server) GracefulStop()

func (*Server) GrpcServer

func (s *Server) GrpcServer() *grpc.Server

Can be used to register more services on the server. Should only be accessed before `Serve` is called.

func (*Server) Listeners

func (s *Server) Listeners() (Listeners, error)

func (*Server) Serve

func (s *Server) Serve(listeners Listeners)

type ServerArgs

type ServerArgs struct {
	Logger   *logrus.Entry
	HttpHost string

	HttpListenAddr string
	GrpcListenAddr string

	FS       filesys.Filesys
	DBCache  DBCache
	ReadOnly bool
	Options  []grpc.ServerOption

	ConcurrencyControl remotesapi.PushConcurrencyControl

	HttpInterceptor func(http.Handler) http.Handler

	// If supplied, the listener(s) returned from Listeners() will be TLS
	// listeners. The scheme used in the URLs returned from the gRPC server
	// will be https.
	TLSConfig *tls.Config
}

type ServerInterceptor

type ServerInterceptor struct {
	Lgr              *logrus.Entry
	AccessController AccessControl
}

func (*ServerInterceptor) Options

func (si *ServerInterceptor) Options() []grpc.ServerOption

func (*ServerInterceptor) Stream

func (*ServerInterceptor) Unary

Jump to

Keyboard shortcuts

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