core

package module
v0.0.0-...-9f27894 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: BSD-3-Clause-Clear Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatusCode_name = map[int32]string{
		0: "Unknown",
		1: "Ok",
		2: "Failed",
	}
	StatusCode_value = map[string]int32{
		"Unknown": 0,
		"Ok":      1,
		"Failed":  2,
	}
)

Enum value maps for StatusCode.

View Source
var (
	HealthCheckResponse_ServingStatus_name = map[int32]string{
		0: "UNKNOWN",
		1: "SERVING",
		2: "NOT_SERVING",
	}
	HealthCheckResponse_ServingStatus_value = map[string]int32{
		"UNKNOWN":     0,
		"SERVING":     1,
		"NOT_SERVING": 2,
	}
)

Enum value maps for HealthCheckResponse_ServingStatus.

View Source
var DownloadCommand = cli.Command{
	Name:   "download",
	Usage:  "download a file",
	Action: downloadAction,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "address",
			Value: "localhost:1313",
			Usage: "address of the server to connect to",
		},
		&cli.StringFlag{
			Name:  "file",
			Usage: "filename to download",
		},
		&cli.StringFlag{
			Name:  "cacert",
			Usage: "path of a certifcate to add to the root CAs",
		},
		&cli.StringFlag{
			Name:  "servername-override",
			Usage: "use serverNameOverride for tls ca cert",
		},
	},
}
View Source
var File_service_proto protoreflect.FileDescriptor
View Source
var HealthCheckCommand = cli.Command{
	Name:   "ping",
	Usage:  "health check",
	Action: healtCheckAction,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "address",
			Value: "localhost:1313",
			Usage: "address of the server to connect to",
		},
		&cli.StringFlag{
			Name:  "label",
			Value: "local",
			Usage: "Default: local. receiving server used to identify ping-client",
		},
		&cli.StringFlag{
			Name:  "interval",
			Value: "1s",
			Usage: "Default 1s. e.g. 1s, 5s, 100ms, 1h",
		},
		&cli.StringFlag{
			Name:  "cacert",
			Usage: "path of a certifcate to add to the root CAs",
		},
		&cli.StringFlag{
			Name:  "servername-override",
			Usage: "use serverNameOverride for tls ca cert",
		},
	},
}
View Source
var ServeCommand = cli.Command{
	Name:   "serve",
	Usage:  "initiates a gRPC upload server (max 4MB per file)",
	Action: serveAction,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:  "port",
			Usage: "port to bind to",
			Value: 1313,
		},
		&cli.StringFlag{
			Name:  "key",
			Usage: "path to TLS key",
		},
		&cli.StringFlag{
			Name:  "certificate",
			Usage: "path to TLS certificate",
		},
	},
}
View Source
var UploadCommand = cli.Command{
	Name:   "upload",
	Usage:  "upload a file (max 4MB per file)",
	Action: uploadAction,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "address",
			Value: "localhost:1313",
			Usage: "address of the server to connect to",
		},
		&cli.StringFlag{
			Name:  "infile",
			Usage: "local filename to upload",
		},
		&cli.StringFlag{
			Name:  "cacert",
			Usage: "path of a certifcate to add to the root CAs",
		},
		&cli.StringFlag{
			Name:  "servername-override",
			Usage: "use serverNameOverride for tls ca cert",
		},
		&cli.StringFlag{
			Name:  "outfile",
			Usage: "output filename after upload",
		},
		&cli.BoolFlag{
			Name:  "public",
			Usage: "send to public download folder",
			Value: false,
		},
	},
}

Functions

func RegisterGuploadServiceServer

func RegisterGuploadServiceServer(s *grpc.Server, srv GuploadServiceServer)

Types

type Chunk

type Chunk struct {

	// Types that are assignable to Data:
	//	*Chunk_Content
	//	*Chunk_Info
	Data isChunk_Data `protobuf_oneof:"data"`
	// contains filtered or unexported fields
}

func (*Chunk) Descriptor deprecated

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

Deprecated: Use Chunk.ProtoReflect.Descriptor instead.

func (*Chunk) GetContent

func (x *Chunk) GetContent() []byte

func (*Chunk) GetData

func (m *Chunk) GetData() isChunk_Data

func (*Chunk) GetInfo

func (x *Chunk) GetInfo() *UploadFileInfo

func (*Chunk) ProtoMessage

func (*Chunk) ProtoMessage()

func (*Chunk) ProtoReflect

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

func (*Chunk) Reset

func (x *Chunk) Reset()

func (*Chunk) String

func (x *Chunk) String() string

type Chunk_Content

type Chunk_Content struct {
	Content []byte `protobuf:"bytes,1,opt,name=Content,proto3,oneof"`
}

type Chunk_Info

type Chunk_Info struct {
	Info *UploadFileInfo `protobuf:"bytes,2,opt,name=info,proto3,oneof"`
}

type Client

type Client interface {
	UploadFile(ctx context.Context, f string) (stats Stats, err error)
	DownloadFile(f string) (err error)
	Check(ctx context.Context, label string, counter int) (pingStats PingStats, err error)
	Close()
}

type ClientGRPC

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

func NewClientGRPC

func NewClientGRPC(cfg ClientGRPCConfig) (c ClientGRPC, err error)

func (*ClientGRPC) Check

func (c *ClientGRPC) Check(ctx context.Context, label string, counter int) (pingStats PingStats, err error)

func (*ClientGRPC) Close

func (c *ClientGRPC) Close()

func (*ClientGRPC) DownloadFile

func (c *ClientGRPC) DownloadFile(fileName string) (err error)

func (*ClientGRPC) UploadFile

func (c *ClientGRPC) UploadFile(ctx context.Context, f string) (stats Stats, err error)

type ClientGRPCConfig

type ClientGRPCConfig struct {
	Address            string
	RootCertificate    string
	Compress           bool
	ServerNameOverride string
	Filename           string
	UsePublicFolder    bool
}

type DiskStore

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

func NewDiskStore

func NewDiskStore(folder string) *DiskStore

func (*DiskStore) Save

func (store *DiskStore) Save(fileId string, fileType string, binaryData bytes.Buffer) (string, error)

type FileInfo

type FileInfo struct {
	FileId string
	Type   string
	Path   string
}

type FileRequest

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

Download

func (*FileRequest) Descriptor deprecated

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

Deprecated: Use FileRequest.ProtoReflect.Descriptor instead.

func (*FileRequest) GetFilename

func (x *FileRequest) GetFilename() string

func (*FileRequest) ProtoMessage

func (*FileRequest) ProtoMessage()

func (*FileRequest) ProtoReflect

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

func (*FileRequest) Reset

func (x *FileRequest) Reset()

func (*FileRequest) String

func (x *FileRequest) String() string

type FileResponse

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

func (*FileResponse) Descriptor deprecated

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

Deprecated: Use FileResponse.ProtoReflect.Descriptor instead.

func (*FileResponse) GetShard

func (x *FileResponse) GetShard() []byte

func (*FileResponse) ProtoMessage

func (*FileResponse) ProtoMessage()

func (*FileResponse) ProtoReflect

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

func (*FileResponse) Reset

func (x *FileResponse) Reset()

func (*FileResponse) String

func (x *FileResponse) String() string

type FileStore

type FileStore interface {
	Save(fileId string, fileType string, binaryData bytes.Buffer) (string, error)
}

type GuploadServiceClient

type GuploadServiceClient interface {
	Upload(ctx context.Context, opts ...grpc.CallOption) (GuploadService_UploadClient, error)
	Download(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (GuploadService_DownloadClient, error)
	Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
}

GuploadServiceClient is the client API for GuploadService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type GuploadServiceServer

GuploadServiceServer is the server API for GuploadService service.

type GuploadService_DownloadClient

type GuploadService_DownloadClient interface {
	Recv() (*FileResponse, error)
	grpc.ClientStream
}

type GuploadService_DownloadServer

type GuploadService_DownloadServer interface {
	Send(*FileResponse) error
	grpc.ServerStream
}

type GuploadService_UploadClient

type GuploadService_UploadClient interface {
	Send(*Chunk) error
	CloseAndRecv() (*UploadStatus, error)
	grpc.ClientStream
}

type GuploadService_UploadServer

type GuploadService_UploadServer interface {
	SendAndClose(*UploadStatus) error
	Recv() (*Chunk, error)
	grpc.ServerStream
}

type Health

type Health interface {
	// Check returns if server is healthy or not
	Check(c context.Context) (bool, error)
}

Health defines a health-check connection.

type HealthCheckRequest

type HealthCheckRequest struct {
	Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	PingAt  string `protobuf:"bytes,2,opt,name=pingAt,proto3" json:"pingAt,omitempty"`
	Label   string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"`
	Counter string `protobuf:"bytes,4,opt,name=counter,proto3" json:"counter,omitempty"`
	// contains filtered or unexported fields
}

func (*HealthCheckRequest) Descriptor deprecated

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

Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.

func (*HealthCheckRequest) GetCounter

func (x *HealthCheckRequest) GetCounter() string

func (*HealthCheckRequest) GetLabel

func (x *HealthCheckRequest) GetLabel() string

func (*HealthCheckRequest) GetPingAt

func (x *HealthCheckRequest) GetPingAt() string

func (*HealthCheckRequest) GetService

func (x *HealthCheckRequest) GetService() string

func (*HealthCheckRequest) ProtoMessage

func (*HealthCheckRequest) ProtoMessage()

func (*HealthCheckRequest) ProtoReflect

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

func (*HealthCheckRequest) Reset

func (x *HealthCheckRequest) Reset()

func (*HealthCheckRequest) String

func (x *HealthCheckRequest) String() string

type HealthCheckResponse

type HealthCheckResponse struct {
	Status     HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=HealthCheckResponse_ServingStatus" json:"status,omitempty"`
	ReceivedAt string                            `protobuf:"bytes,2,opt,name=receivedAt,proto3" json:"receivedAt,omitempty"`
	// contains filtered or unexported fields
}

func (*HealthCheckResponse) Descriptor deprecated

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

Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.

func (*HealthCheckResponse) GetReceivedAt

func (x *HealthCheckResponse) GetReceivedAt() string

func (*HealthCheckResponse) GetStatus

func (*HealthCheckResponse) ProtoMessage

func (*HealthCheckResponse) ProtoMessage()

func (*HealthCheckResponse) ProtoReflect

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

func (*HealthCheckResponse) Reset

func (x *HealthCheckResponse) Reset()

func (*HealthCheckResponse) String

func (x *HealthCheckResponse) String() string

type HealthCheckResponse_ServingStatus

type HealthCheckResponse_ServingStatus int32
const (
	HealthCheckResponse_UNKNOWN     HealthCheckResponse_ServingStatus = 0
	HealthCheckResponse_SERVING     HealthCheckResponse_ServingStatus = 1
	HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2
)

func (HealthCheckResponse_ServingStatus) Descriptor

func (HealthCheckResponse_ServingStatus) Enum

func (HealthCheckResponse_ServingStatus) EnumDescriptor deprecated

func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use HealthCheckResponse_ServingStatus.Descriptor instead.

func (HealthCheckResponse_ServingStatus) Number

func (HealthCheckResponse_ServingStatus) String

func (HealthCheckResponse_ServingStatus) Type

type PingStats

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

type Server

type Server interface {
	Listen() (err error)
	Close()
}

type ServerGRPC

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

func NewServerGRPC

func NewServerGRPC(cfg ServerGRPCConfig, fileStore FileStore) (s ServerGRPC, err error)

func (*ServerGRPC) Check

func (*ServerGRPC) Close

func (s *ServerGRPC) Close()

func (*ServerGRPC) Download

func (s *ServerGRPC) Download(request *FileRequest, stream GuploadService_DownloadServer) error

func (*ServerGRPC) Listen

func (s *ServerGRPC) Listen() (err error)

func (*ServerGRPC) Upload

func (s *ServerGRPC) Upload(stream GuploadService_UploadServer) (err error)

type ServerGRPCConfig

type ServerGRPCConfig struct {
	Certificate string
	Key         string
	Port        int
}

type Stats

type Stats struct {
	StartedAt  time.Time
	FinishedAt time.Time
}

type StatusCode

type StatusCode int32
const (
	StatusCode_Unknown StatusCode = 0
	StatusCode_Ok      StatusCode = 1
	StatusCode_Failed  StatusCode = 2
)

func (StatusCode) Descriptor

func (StatusCode) Descriptor() protoreflect.EnumDescriptor

func (StatusCode) Enum

func (x StatusCode) Enum() *StatusCode

func (StatusCode) EnumDescriptor deprecated

func (StatusCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use StatusCode.Descriptor instead.

func (StatusCode) Number

func (x StatusCode) Number() protoreflect.EnumNumber

func (StatusCode) String

func (x StatusCode) String() string

func (StatusCode) Type

type UnimplementedGuploadServiceServer

type UnimplementedGuploadServiceServer struct {
}

UnimplementedGuploadServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedGuploadServiceServer) Check

func (*UnimplementedGuploadServiceServer) Download

func (*UnimplementedGuploadServiceServer) Upload

type UploadFileInfo

type UploadFileInfo struct {
	Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
	FileType string `protobuf:"bytes,2,opt,name=fileType,proto3" json:"fileType,omitempty"`
	// contains filtered or unexported fields
}

Upload

func (*UploadFileInfo) Descriptor deprecated

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

Deprecated: Use UploadFileInfo.ProtoReflect.Descriptor instead.

func (*UploadFileInfo) GetFileType

func (x *UploadFileInfo) GetFileType() string

func (*UploadFileInfo) GetFilename

func (x *UploadFileInfo) GetFilename() string

func (*UploadFileInfo) ProtoMessage

func (*UploadFileInfo) ProtoMessage()

func (*UploadFileInfo) ProtoReflect

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

func (*UploadFileInfo) Reset

func (x *UploadFileInfo) Reset()

func (*UploadFileInfo) String

func (x *UploadFileInfo) String() string

type UploadStatus

type UploadStatus struct {
	Message string     `protobuf:"bytes,1,opt,name=Message,proto3" json:"Message,omitempty"`
	Code    StatusCode `protobuf:"varint,2,opt,name=Code,proto3,enum=StatusCode" json:"Code,omitempty"`
	// contains filtered or unexported fields
}

func (*UploadStatus) Descriptor deprecated

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

Deprecated: Use UploadStatus.ProtoReflect.Descriptor instead.

func (*UploadStatus) GetCode

func (x *UploadStatus) GetCode() StatusCode

func (*UploadStatus) GetMessage

func (x *UploadStatus) GetMessage() string

func (*UploadStatus) ProtoMessage

func (*UploadStatus) ProtoMessage()

func (*UploadStatus) ProtoReflect

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

func (*UploadStatus) Reset

func (x *UploadStatus) Reset()

func (*UploadStatus) String

func (x *UploadStatus) String() string

Jump to

Keyboard shortcuts

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