plugin

package
v0.0.0-...-5e8511f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoUser = &Error{Message: "No user specified"}
View Source
var File_storage_proto protoreflect.FileDescriptor
View Source
var StorageProvider_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "leichtcloud.storage.plugin.StorageProvider",
	HandlerType: (*StorageProviderServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Configure",
			Handler:    _StorageProvider_Configure_Handler,
		},
		{
			MethodName: "InitUser",
			Handler:    _StorageProvider_InitUser_Handler,
		},
		{
			MethodName: "MkDir",
			Handler:    _StorageProvider_MkDir_Handler,
		},
		{
			MethodName: "Move",
			Handler:    _StorageProvider_Move_Handler,
		},
		{
			MethodName: "OpenFile",
			Handler:    _StorageProvider_OpenFile_Handler,
		},
		{
			MethodName: "CloseFile",
			Handler:    _StorageProvider_CloseFile_Handler,
		},
		{
			MethodName: "WriteFile",
			Handler:    _StorageProvider_WriteFile_Handler,
		},
		{
			MethodName: "Delete",
			Handler:    _StorageProvider_Delete_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListDirectory",
			Handler:       _StorageProvider_ListDirectory_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "ReadFile",
			Handler:       _StorageProvider_ReadFile_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "storage.proto",
}

StorageProvider_ServiceDesc is the grpc.ServiceDesc for StorageProvider service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterStorageProviderServer

func RegisterStorageProviderServer(s grpc.ServiceRegistrar, srv StorageProviderServer)

func Start

func Start(storage storage.StorageProvider) (err error)

This is meant to be called in the main() of your plugin

Types

type BridgeStorageProviderServer

type BridgeStorageProviderServer struct {
	Storage storage.StorageProvider
	// contains filtered or unexported fields
}

func (*BridgeStorageProviderServer) CloseFile

func (*BridgeStorageProviderServer) Configure

func (s *BridgeStorageProviderServer) Configure(ctx context.Context, req *ConfigData) (*Error, error)

func (*BridgeStorageProviderServer) Delete

func (*BridgeStorageProviderServer) InitUser

func (s *BridgeStorageProviderServer) InitUser(ctx context.Context, req *User) (*Error, error)

func (*BridgeStorageProviderServer) ListDirectory

func (*BridgeStorageProviderServer) MkDir

func (*BridgeStorageProviderServer) Move

func (*BridgeStorageProviderServer) OpenFile

func (*BridgeStorageProviderServer) ReadFile

func (*BridgeStorageProviderServer) WriteFile

type CloseFileQuery

type CloseFileQuery struct {
	Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*CloseFileQuery) Descriptor deprecated

func (*CloseFileQuery) Descriptor() ([]byte, []int)

Deprecated: Use CloseFileQuery.ProtoReflect.Descriptor instead.

func (*CloseFileQuery) GetId

func (x *CloseFileQuery) GetId() int32

func (*CloseFileQuery) ProtoMessage

func (*CloseFileQuery) ProtoMessage()

func (*CloseFileQuery) ProtoReflect

func (x *CloseFileQuery) ProtoReflect() protoreflect.Message

func (*CloseFileQuery) Reset

func (x *CloseFileQuery) Reset()

func (*CloseFileQuery) String

func (x *CloseFileQuery) String() string

type ConfigData

type ConfigData struct {
	Yaml []byte `protobuf:"bytes,1,opt,name=yaml,proto3" json:"yaml,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfigData) Descriptor deprecated

func (*ConfigData) Descriptor() ([]byte, []int)

Deprecated: Use ConfigData.ProtoReflect.Descriptor instead.

func (*ConfigData) GetYaml

func (x *ConfigData) GetYaml() []byte

func (*ConfigData) ProtoMessage

func (*ConfigData) ProtoMessage()

func (*ConfigData) ProtoReflect

func (x *ConfigData) ProtoReflect() protoreflect.Message

func (*ConfigData) Reset

func (x *ConfigData) Reset()

func (*ConfigData) String

func (x *ConfigData) String() string

type DeleteQuery

type DeleteQuery struct {
	User     *User  `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	FullPath string `protobuf:"bytes,2,opt,name=fullPath,proto3" json:"fullPath,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteQuery) Descriptor deprecated

func (*DeleteQuery) Descriptor() ([]byte, []int)

Deprecated: Use DeleteQuery.ProtoReflect.Descriptor instead.

func (*DeleteQuery) GetFullPath

func (x *DeleteQuery) GetFullPath() string

func (*DeleteQuery) GetUser

func (x *DeleteQuery) GetUser() *User

func (*DeleteQuery) ProtoMessage

func (*DeleteQuery) ProtoMessage()

func (*DeleteQuery) ProtoReflect

func (x *DeleteQuery) ProtoReflect() protoreflect.Message

func (*DeleteQuery) Reset

func (x *DeleteQuery) Reset()

func (*DeleteQuery) String

func (x *DeleteQuery) String() string

type Error

type Error struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type File

type File struct {
	Storage *GrpcStorage
	Id      int32
	// contains filtered or unexported fields
}

func (*File) Close

func (f *File) Close() (err error)

func (*File) Read

func (f *File) Read(p []byte) (int, error)

func (*File) Write

func (f *File) Write(p []byte) (int, error)

type FileInfo

type FileInfo struct {
	Name      string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	FullPath  string `protobuf:"bytes,2,opt,name=fullPath,proto3" json:"fullPath,omitempty"`
	CreatedAt uint64 `protobuf:"varint,3,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
	UpdatedAt uint64 `protobuf:"varint,4,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"`
	Size      uint64 `protobuf:"varint,5,opt,name=size,proto3" json:"size,omitempty"`
	Directory bool   `protobuf:"varint,6,opt,name=directory,proto3" json:"directory,omitempty"`
	// contains filtered or unexported fields
}

This basically maps to the FileInfo struct

func (*FileInfo) Descriptor deprecated

func (*FileInfo) Descriptor() ([]byte, []int)

Deprecated: Use FileInfo.ProtoReflect.Descriptor instead.

func (*FileInfo) GetCreatedAt

func (x *FileInfo) GetCreatedAt() uint64

func (*FileInfo) GetDirectory

func (x *FileInfo) GetDirectory() bool

func (*FileInfo) GetFullPath

func (x *FileInfo) GetFullPath() string

func (*FileInfo) GetName

func (x *FileInfo) GetName() string

func (*FileInfo) GetSize

func (x *FileInfo) GetSize() uint64

func (*FileInfo) GetUpdatedAt

func (x *FileInfo) GetUpdatedAt() uint64

func (*FileInfo) ProtoMessage

func (*FileInfo) ProtoMessage()

func (*FileInfo) ProtoReflect

func (x *FileInfo) ProtoReflect() protoreflect.Message

func (*FileInfo) Reset

func (x *FileInfo) Reset()

func (*FileInfo) String

func (x *FileInfo) String() string

type GrpcStorage

type GrpcStorage struct {
	Conn   *grpc.ClientConn
	Client StorageProviderClient
	// contains filtered or unexported fields
}

func NewGrpcStorage

func NewGrpcStorage(conn *grpc.ClientConn, config map[interface{}]interface{}) (*GrpcStorage, error)

func (*GrpcStorage) Close

func (s *GrpcStorage) Close() error

func (*GrpcStorage) Delete

func (s *GrpcStorage) Delete(ctx context.Context, user *models.User, fullpath string) error

func (*GrpcStorage) File

func (s *GrpcStorage) File(ctx context.Context, user *models.User, fullpath string) (storage.File, error)

func (*GrpcStorage) InitUser

func (s *GrpcStorage) InitUser(ctx context.Context, user *models.User) error

func (*GrpcStorage) ListDirectory

func (s *GrpcStorage) ListDirectory(ctx context.Context, user *models.User, path string) (<-chan storage.FileInfo, error)

func (*GrpcStorage) Mkdir

func (s *GrpcStorage) Mkdir(ctx context.Context, user *models.User, path string) error

func (*GrpcStorage) Move

func (s *GrpcStorage) Move(ctx context.Context, user *models.User, src, dst string) error

type ListDirectoryQuery

type ListDirectoryQuery struct {
	User *User  `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

func (*ListDirectoryQuery) Descriptor deprecated

func (*ListDirectoryQuery) Descriptor() ([]byte, []int)

Deprecated: Use ListDirectoryQuery.ProtoReflect.Descriptor instead.

func (*ListDirectoryQuery) GetPath

func (x *ListDirectoryQuery) GetPath() string

func (*ListDirectoryQuery) GetUser

func (x *ListDirectoryQuery) GetUser() *User

func (*ListDirectoryQuery) ProtoMessage

func (*ListDirectoryQuery) ProtoMessage()

func (*ListDirectoryQuery) ProtoReflect

func (x *ListDirectoryQuery) ProtoReflect() protoreflect.Message

func (*ListDirectoryQuery) Reset

func (x *ListDirectoryQuery) Reset()

func (*ListDirectoryQuery) String

func (x *ListDirectoryQuery) String() string

type MkdirQuery

type MkdirQuery struct {
	User *User  `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

func (*MkdirQuery) Descriptor deprecated

func (*MkdirQuery) Descriptor() ([]byte, []int)

Deprecated: Use MkdirQuery.ProtoReflect.Descriptor instead.

func (*MkdirQuery) GetPath

func (x *MkdirQuery) GetPath() string

func (*MkdirQuery) GetUser

func (x *MkdirQuery) GetUser() *User

func (*MkdirQuery) ProtoMessage

func (*MkdirQuery) ProtoMessage()

func (*MkdirQuery) ProtoReflect

func (x *MkdirQuery) ProtoReflect() protoreflect.Message

func (*MkdirQuery) Reset

func (x *MkdirQuery) Reset()

func (*MkdirQuery) String

func (x *MkdirQuery) String() string

type MoveQuery

type MoveQuery struct {
	User *User  `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	Src  string `protobuf:"bytes,2,opt,name=src,proto3" json:"src,omitempty"`
	Dst  string `protobuf:"bytes,3,opt,name=dst,proto3" json:"dst,omitempty"`
	// contains filtered or unexported fields
}

func (*MoveQuery) Descriptor deprecated

func (*MoveQuery) Descriptor() ([]byte, []int)

Deprecated: Use MoveQuery.ProtoReflect.Descriptor instead.

func (*MoveQuery) GetDst

func (x *MoveQuery) GetDst() string

func (*MoveQuery) GetSrc

func (x *MoveQuery) GetSrc() string

func (*MoveQuery) GetUser

func (x *MoveQuery) GetUser() *User

func (*MoveQuery) ProtoMessage

func (*MoveQuery) ProtoMessage()

func (*MoveQuery) ProtoReflect

func (x *MoveQuery) ProtoReflect() protoreflect.Message

func (*MoveQuery) Reset

func (x *MoveQuery) Reset()

func (*MoveQuery) String

func (x *MoveQuery) String() string

type OpenFileQuery

type OpenFileQuery struct {
	User     *User  `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	FullPath string `protobuf:"bytes,2,opt,name=fullPath,proto3" json:"fullPath,omitempty"`
	// contains filtered or unexported fields
}

func (*OpenFileQuery) Descriptor deprecated

func (*OpenFileQuery) Descriptor() ([]byte, []int)

Deprecated: Use OpenFileQuery.ProtoReflect.Descriptor instead.

func (*OpenFileQuery) GetFullPath

func (x *OpenFileQuery) GetFullPath() string

func (*OpenFileQuery) GetUser

func (x *OpenFileQuery) GetUser() *User

func (*OpenFileQuery) ProtoMessage

func (*OpenFileQuery) ProtoMessage()

func (*OpenFileQuery) ProtoReflect

func (x *OpenFileQuery) ProtoReflect() protoreflect.Message

func (*OpenFileQuery) Reset

func (x *OpenFileQuery) Reset()

func (*OpenFileQuery) String

func (x *OpenFileQuery) String() string

type OpenFileReply

type OpenFileReply struct {
	Id    int32  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Error *Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*OpenFileReply) Descriptor deprecated

func (*OpenFileReply) Descriptor() ([]byte, []int)

Deprecated: Use OpenFileReply.ProtoReflect.Descriptor instead.

func (*OpenFileReply) GetError

func (x *OpenFileReply) GetError() *Error

func (*OpenFileReply) GetId

func (x *OpenFileReply) GetId() int32

func (*OpenFileReply) ProtoMessage

func (*OpenFileReply) ProtoMessage()

func (*OpenFileReply) ProtoReflect

func (x *OpenFileReply) ProtoReflect() protoreflect.Message

func (*OpenFileReply) Reset

func (x *OpenFileReply) Reset()

func (*OpenFileReply) String

func (x *OpenFileReply) String() string

type ReadFileQuery

type ReadFileQuery struct {
	Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadFileQuery) Descriptor deprecated

func (*ReadFileQuery) Descriptor() ([]byte, []int)

Deprecated: Use ReadFileQuery.ProtoReflect.Descriptor instead.

func (*ReadFileQuery) GetId

func (x *ReadFileQuery) GetId() int32

func (*ReadFileQuery) ProtoMessage

func (*ReadFileQuery) ProtoMessage()

func (*ReadFileQuery) ProtoReflect

func (x *ReadFileQuery) ProtoReflect() protoreflect.Message

func (*ReadFileQuery) Reset

func (x *ReadFileQuery) Reset()

func (*ReadFileQuery) String

func (x *ReadFileQuery) String() string

type ReadFileReply

type ReadFileReply struct {
	Data  []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	EOF   bool   `protobuf:"varint,2,opt,name=EOF,proto3" json:"EOF,omitempty"`
	Error *Error `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadFileReply) Descriptor deprecated

func (*ReadFileReply) Descriptor() ([]byte, []int)

Deprecated: Use ReadFileReply.ProtoReflect.Descriptor instead.

func (*ReadFileReply) GetData

func (x *ReadFileReply) GetData() []byte

func (*ReadFileReply) GetEOF

func (x *ReadFileReply) GetEOF() bool

func (*ReadFileReply) GetError

func (x *ReadFileReply) GetError() *Error

func (*ReadFileReply) ProtoMessage

func (*ReadFileReply) ProtoMessage()

func (*ReadFileReply) ProtoReflect

func (x *ReadFileReply) ProtoReflect() protoreflect.Message

func (*ReadFileReply) Reset

func (x *ReadFileReply) Reset()

func (*ReadFileReply) String

func (x *ReadFileReply) String() string

type StorageProviderClient

type StorageProviderClient interface {
	Configure(ctx context.Context, in *ConfigData, opts ...grpc.CallOption) (*Error, error)
	InitUser(ctx context.Context, in *User, opts ...grpc.CallOption) (*Error, error)
	MkDir(ctx context.Context, in *MkdirQuery, opts ...grpc.CallOption) (*Error, error)
	Move(ctx context.Context, in *MoveQuery, opts ...grpc.CallOption) (*Error, error)
	ListDirectory(ctx context.Context, in *ListDirectoryQuery, opts ...grpc.CallOption) (StorageProvider_ListDirectoryClient, error)
	OpenFile(ctx context.Context, in *OpenFileQuery, opts ...grpc.CallOption) (*OpenFileReply, error)
	CloseFile(ctx context.Context, in *CloseFileQuery, opts ...grpc.CallOption) (*Error, error)
	WriteFile(ctx context.Context, in *WriteFileQuery, opts ...grpc.CallOption) (*WriteFileReply, error)
	ReadFile(ctx context.Context, in *ReadFileQuery, opts ...grpc.CallOption) (StorageProvider_ReadFileClient, error)
	Delete(ctx context.Context, in *DeleteQuery, opts ...grpc.CallOption) (*Error, error)
}

StorageProviderClient is the client API for StorageProvider service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.golang.ir/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type StorageProviderServer

type StorageProviderServer interface {
	Configure(context.Context, *ConfigData) (*Error, error)
	InitUser(context.Context, *User) (*Error, error)
	MkDir(context.Context, *MkdirQuery) (*Error, error)
	Move(context.Context, *MoveQuery) (*Error, error)
	ListDirectory(*ListDirectoryQuery, StorageProvider_ListDirectoryServer) error
	OpenFile(context.Context, *OpenFileQuery) (*OpenFileReply, error)
	CloseFile(context.Context, *CloseFileQuery) (*Error, error)
	WriteFile(context.Context, *WriteFileQuery) (*WriteFileReply, error)
	ReadFile(*ReadFileQuery, StorageProvider_ReadFileServer) error
	Delete(context.Context, *DeleteQuery) (*Error, error)
	// contains filtered or unexported methods
}

StorageProviderServer is the server API for StorageProvider service. All implementations must embed UnimplementedStorageProviderServer for forward compatibility

type StorageProvider_ListDirectoryClient

type StorageProvider_ListDirectoryClient interface {
	Recv() (*FileInfo, error)
	grpc.ClientStream
}

type StorageProvider_ListDirectoryServer

type StorageProvider_ListDirectoryServer interface {
	Send(*FileInfo) error
	grpc.ServerStream
}

type StorageProvider_ReadFileClient

type StorageProvider_ReadFileClient interface {
	Recv() (*ReadFileReply, error)
	grpc.ClientStream
}

type StorageProvider_ReadFileServer

type StorageProvider_ReadFileServer interface {
	Send(*ReadFileReply) error
	grpc.ServerStream
}

type UnimplementedStorageProviderServer

type UnimplementedStorageProviderServer struct {
}

UnimplementedStorageProviderServer must be embedded to have forward compatible implementations.

func (UnimplementedStorageProviderServer) CloseFile

func (UnimplementedStorageProviderServer) Configure

func (UnimplementedStorageProviderServer) Delete

func (UnimplementedStorageProviderServer) InitUser

func (UnimplementedStorageProviderServer) ListDirectory

func (UnimplementedStorageProviderServer) MkDir

func (UnimplementedStorageProviderServer) Move

func (UnimplementedStorageProviderServer) OpenFile

func (UnimplementedStorageProviderServer) ReadFile

func (UnimplementedStorageProviderServer) WriteFile

type UnsafeStorageProviderServer

type UnsafeStorageProviderServer interface {
	// contains filtered or unexported methods
}

UnsafeStorageProviderServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to StorageProviderServer will result in compilation errors.

type User

type User struct {
	Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

This sort of maps to the User struct, although we only give the id as that should be the only relevant thing.

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetId

func (x *User) GetId() uint64

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type WriteFileQuery

type WriteFileQuery struct {
	Id   int32  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*WriteFileQuery) Descriptor deprecated

func (*WriteFileQuery) Descriptor() ([]byte, []int)

Deprecated: Use WriteFileQuery.ProtoReflect.Descriptor instead.

func (*WriteFileQuery) GetData

func (x *WriteFileQuery) GetData() []byte

func (*WriteFileQuery) GetId

func (x *WriteFileQuery) GetId() int32

func (*WriteFileQuery) ProtoMessage

func (*WriteFileQuery) ProtoMessage()

func (*WriteFileQuery) ProtoReflect

func (x *WriteFileQuery) ProtoReflect() protoreflect.Message

func (*WriteFileQuery) Reset

func (x *WriteFileQuery) Reset()

func (*WriteFileQuery) String

func (x *WriteFileQuery) String() string

type WriteFileReply

type WriteFileReply struct {
	SizeWritten int32  `protobuf:"varint,1,opt,name=size_written,json=sizeWritten,proto3" json:"size_written,omitempty"`
	Error       *Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*WriteFileReply) Descriptor deprecated

func (*WriteFileReply) Descriptor() ([]byte, []int)

Deprecated: Use WriteFileReply.ProtoReflect.Descriptor instead.

func (*WriteFileReply) GetError

func (x *WriteFileReply) GetError() *Error

func (*WriteFileReply) GetSizeWritten

func (x *WriteFileReply) GetSizeWritten() int32

func (*WriteFileReply) ProtoMessage

func (*WriteFileReply) ProtoMessage()

func (*WriteFileReply) ProtoReflect

func (x *WriteFileReply) ProtoReflect() protoreflect.Message

func (*WriteFileReply) Reset

func (x *WriteFileReply) Reset()

func (*WriteFileReply) String

func (x *WriteFileReply) String() string

Jump to

Keyboard shortcuts

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