move implementations to external repos (#17)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// +build ignore
|
||||
|
||||
package client_test
|
||||
|
||||
import (
|
||||
|
@@ -1,201 +0,0 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
proto "github.com/unistack-org/micro/v3/util/file/proto"
|
||||
)
|
||||
|
||||
// Client is the client interface to access files
|
||||
type File interface {
|
||||
Open(filename string, truncate bool) (int64, error)
|
||||
Stat(filename string) (*proto.StatResponse, error)
|
||||
GetBlock(sessionId, blockId int64) ([]byte, error)
|
||||
ReadAt(sessionId, offset, size int64) ([]byte, error)
|
||||
Read(sessionId int64, buf []byte) (int, error)
|
||||
Write(sessionId, offset int64, data []byte) error
|
||||
Close(sessionId int64) error
|
||||
Download(filename, saveFile string) error
|
||||
Upload(filename, localFile string) error
|
||||
DownloadAt(filename, saveFile string, blockId int) error
|
||||
}
|
||||
|
||||
// NewClient returns a new Client which uses a micro Client
|
||||
func New(service string, c client.Client, opts ...Option) File {
|
||||
options := Options{
|
||||
Context: context.TODO(),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
return &fc{
|
||||
c: proto.NewFileService(service, c),
|
||||
opts: options,
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
blockSize = 512 * 1024
|
||||
)
|
||||
|
||||
type fc struct {
|
||||
c proto.FileService
|
||||
opts Options
|
||||
}
|
||||
|
||||
func (c *fc) Open(filename string, truncate bool) (int64, error) {
|
||||
rsp, err := c.c.Open(c.opts.Context, &proto.OpenRequest{
|
||||
Filename: filename,
|
||||
Truncate: truncate,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return rsp.Id, nil
|
||||
}
|
||||
|
||||
func (c *fc) Stat(filename string) (*proto.StatResponse, error) {
|
||||
return c.c.Stat(c.opts.Context, &proto.StatRequest{Filename: filename})
|
||||
}
|
||||
|
||||
func (c *fc) GetBlock(sessionId, blockId int64) ([]byte, error) {
|
||||
return c.ReadAt(sessionId, blockId*blockSize, blockSize)
|
||||
}
|
||||
|
||||
func (c *fc) ReadAt(sessionId, offset, size int64) ([]byte, error) {
|
||||
rsp, err := c.c.Read(c.opts.Context, &proto.ReadRequest{Id: sessionId, Size: size, Offset: offset})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if rsp.Eof {
|
||||
err = io.EOF
|
||||
}
|
||||
|
||||
if rsp.Data == nil {
|
||||
rsp.Data = make([]byte, size)
|
||||
}
|
||||
|
||||
if size != rsp.Size {
|
||||
return rsp.Data[:rsp.Size], err
|
||||
}
|
||||
|
||||
return rsp.Data, nil
|
||||
}
|
||||
|
||||
func (c *fc) Read(sessionId int64, buf []byte) (int, error) {
|
||||
b, err := c.ReadAt(sessionId, 0, int64(cap(buf)))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
copy(buf, b)
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (c *fc) Write(sessionId, offset int64, data []byte) error {
|
||||
_, err := c.c.Write(c.opts.Context, &proto.WriteRequest{
|
||||
Id: sessionId,
|
||||
Offset: offset,
|
||||
Data: data})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *fc) Close(sessionId int64) error {
|
||||
_, err := c.c.Close(c.opts.Context, &proto.CloseRequest{Id: sessionId})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *fc) Download(filename, saveFile string) error {
|
||||
return c.DownloadAt(filename, saveFile, 0)
|
||||
}
|
||||
|
||||
func (c *fc) Upload(filename, localFile string) error {
|
||||
file, err := os.Open(localFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
offset := 0
|
||||
sessionId, err := c.Open(filename, true)
|
||||
defer c.Close(sessionId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reader := bufio.NewReader(file)
|
||||
part := make([]byte, blockSize)
|
||||
|
||||
for {
|
||||
count, err := reader.Read(part)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
err = c.Write(sessionId, int64(offset), part)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
offset += count
|
||||
}
|
||||
if err != nil && err != io.EOF {
|
||||
return fmt.Errorf("Error reading %v: %v", localFile, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
stat, err := c.Stat(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stat.Type == "Directory" {
|
||||
return fmt.Errorf("%s is directory.", filename)
|
||||
}
|
||||
|
||||
blocks := int(stat.Size / blockSize)
|
||||
if stat.Size%blockSize != 0 {
|
||||
blocks += 1
|
||||
}
|
||||
|
||||
logger.Infof("Download %s in %d blocks", filename, blocks-blockId)
|
||||
|
||||
file, err := os.OpenFile(saveFile, os.O_CREATE|os.O_WRONLY, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
sessionId, err := c.Open(filename, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := blockId; i < blocks; i++ {
|
||||
buf, rerr := c.GetBlock(sessionId, int64(i))
|
||||
if rerr != nil && rerr != io.EOF {
|
||||
return rerr
|
||||
}
|
||||
if _, werr := file.WriteAt(buf, int64(i)*blockSize); werr != nil {
|
||||
return werr
|
||||
}
|
||||
|
||||
if i%((blocks-blockId)/100+1) == 0 {
|
||||
logger.Infof("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
}
|
||||
|
||||
if rerr == io.EOF {
|
||||
break
|
||||
}
|
||||
}
|
||||
logger.Infof("Download %s completed", filename)
|
||||
|
||||
c.Close(sessionId)
|
||||
|
||||
return nil
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package file
|
||||
|
||||
import "os"
|
||||
|
||||
// Exists returns true if the path is existing
|
||||
func Exists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return true, err
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExists(t *testing.T) {
|
||||
ok, err := Exists("/")
|
||||
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
|
||||
if !ok || err != nil {
|
||||
t.Fatalf("Test Exists fail, %s", err)
|
||||
}
|
||||
}
|
@@ -1,154 +0,0 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/unistack-org/micro/v3/errors"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
proto "github.com/unistack-org/micro/v3/util/file/proto"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// NewHandler is a handler that can be registered with a micro Server
|
||||
func NewHandler(readDir string) proto.FileHandler {
|
||||
return &handler{
|
||||
readDir: readDir,
|
||||
session: &session{
|
||||
files: make(map[int64]*os.File),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterHandler is a convenience method for registering a handler
|
||||
func RegisterHandler(s server.Server, readDir string) {
|
||||
proto.RegisterFileHandler(s, NewHandler(readDir))
|
||||
}
|
||||
|
||||
type handler struct {
|
||||
readDir string
|
||||
session *session
|
||||
}
|
||||
|
||||
func (h *handler) Open(ctx context.Context, req *proto.OpenRequest, rsp *proto.OpenResponse) error {
|
||||
path := filepath.Join(h.readDir, req.Filename)
|
||||
flags := os.O_CREATE | os.O_RDWR
|
||||
if req.GetTruncate() {
|
||||
flags |= os.O_TRUNC
|
||||
}
|
||||
file, err := os.OpenFile(path, flags, 0666)
|
||||
if err != nil {
|
||||
return errors.InternalServerError("go.micro.server", err.Error())
|
||||
}
|
||||
|
||||
rsp.Id = h.session.Add(file)
|
||||
rsp.Result = true
|
||||
|
||||
logger.Debugf("Open %s, sessionId=%d", req.Filename, rsp.Id)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) Close(ctx context.Context, req *proto.CloseRequest, rsp *proto.CloseResponse) error {
|
||||
h.session.Delete(req.Id)
|
||||
logger.Debugf("Close sessionId=%d", req.Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) Stat(ctx context.Context, req *proto.StatRequest, rsp *proto.StatResponse) error {
|
||||
path := filepath.Join(h.readDir, req.Filename)
|
||||
fi, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
return errors.InternalServerError("go.micro.srv.file", err.Error())
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
rsp.Type = "Directory"
|
||||
} else {
|
||||
rsp.Type = "File"
|
||||
rsp.Size = fi.Size()
|
||||
}
|
||||
|
||||
rsp.LastModified = fi.ModTime().Unix()
|
||||
logger.Debugf("Stat %s, %#v", req.Filename, rsp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) Read(ctx context.Context, req *proto.ReadRequest, rsp *proto.ReadResponse) error {
|
||||
file := h.session.Get(req.Id)
|
||||
if file == nil {
|
||||
return errors.InternalServerError("go.micro.srv.file", "You must call open first.")
|
||||
}
|
||||
|
||||
rsp.Data = make([]byte, req.Size)
|
||||
n, err := file.ReadAt(rsp.Data, req.Offset)
|
||||
if err != nil && err != io.EOF {
|
||||
return errors.InternalServerError("go.micro.srv.file", err.Error())
|
||||
}
|
||||
|
||||
if err == io.EOF {
|
||||
rsp.Eof = true
|
||||
}
|
||||
|
||||
rsp.Size = int64(n)
|
||||
rsp.Data = rsp.Data[:n]
|
||||
|
||||
logger.Debugf("Read sessionId=%d, Offset=%d, n=%d", req.Id, req.Offset, rsp.Size)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) Write(ctx context.Context, req *proto.WriteRequest, rsp *proto.WriteResponse) error {
|
||||
file := h.session.Get(req.Id)
|
||||
if file == nil {
|
||||
return errors.InternalServerError("go.micro.srv.file", "You must call open first.")
|
||||
}
|
||||
|
||||
if _, err := file.WriteAt(req.GetData(), req.GetOffset()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Debugf("Write session id=%d, Offset=%d,", req.Id, req.Offset)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type session struct {
|
||||
sync.Mutex
|
||||
files map[int64]*os.File
|
||||
counter int64
|
||||
}
|
||||
|
||||
func (s *session) Add(file *os.File) int64 {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
s.counter += 1
|
||||
s.files[s.counter] = file
|
||||
|
||||
return s.counter
|
||||
}
|
||||
|
||||
func (s *session) Get(id int64) *os.File {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
return s.files[id]
|
||||
}
|
||||
|
||||
func (s *session) Delete(id int64) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
if file, exist := s.files[id]; exist {
|
||||
file.Close()
|
||||
delete(s.files, id)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *session) Len() int {
|
||||
return len(s.files)
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package file
|
||||
|
||||
import "context"
|
||||
|
||||
type Options struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
func WithContext(ctx context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = ctx
|
||||
}
|
||||
}
|
@@ -1,967 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc v3.6.1
|
||||
// source: util/file/proto/file.proto
|
||||
|
||||
package go_micro_server
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type OpenRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
|
||||
Truncate bool `protobuf:"varint,2,opt,name=truncate,proto3" json:"truncate,omitempty"`
|
||||
}
|
||||
|
||||
func (x *OpenRequest) Reset() {
|
||||
*x = OpenRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *OpenRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*OpenRequest) ProtoMessage() {}
|
||||
|
||||
func (x *OpenRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use OpenRequest.ProtoReflect.Descriptor instead.
|
||||
func (*OpenRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *OpenRequest) GetFilename() string {
|
||||
if x != nil {
|
||||
return x.Filename
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *OpenRequest) GetTruncate() bool {
|
||||
if x != nil {
|
||||
return x.Truncate
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type OpenResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Result bool `protobuf:"varint,2,opt,name=result,proto3" json:"result,omitempty"`
|
||||
}
|
||||
|
||||
func (x *OpenResponse) Reset() {
|
||||
*x = OpenResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *OpenResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*OpenResponse) ProtoMessage() {}
|
||||
|
||||
func (x *OpenResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use OpenResponse.ProtoReflect.Descriptor instead.
|
||||
func (*OpenResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *OpenResponse) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *OpenResponse) GetResult() bool {
|
||||
if x != nil {
|
||||
return x.Result
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type CloseRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CloseRequest) Reset() {
|
||||
*x = CloseRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CloseRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CloseRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CloseRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CloseRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CloseRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CloseRequest) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type CloseResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *CloseResponse) Reset() {
|
||||
*x = CloseResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CloseResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CloseResponse) ProtoMessage() {}
|
||||
|
||||
func (x *CloseResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CloseResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CloseResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
type StatRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StatRequest) Reset() {
|
||||
*x = StatRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StatRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StatRequest) ProtoMessage() {}
|
||||
|
||||
func (x *StatRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StatRequest.ProtoReflect.Descriptor instead.
|
||||
func (*StatRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *StatRequest) GetFilename() string {
|
||||
if x != nil {
|
||||
return x.Filename
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StatResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
|
||||
Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
|
||||
LastModified int64 `protobuf:"varint,3,opt,name=last_modified,json=lastModified,proto3" json:"last_modified,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StatResponse) Reset() {
|
||||
*x = StatResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StatResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StatResponse) ProtoMessage() {}
|
||||
|
||||
func (x *StatResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StatResponse.ProtoReflect.Descriptor instead.
|
||||
func (*StatResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *StatResponse) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StatResponse) GetSize() int64 {
|
||||
if x != nil {
|
||||
return x.Size
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StatResponse) GetLastModified() int64 {
|
||||
if x != nil {
|
||||
return x.LastModified
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReadRequest) Reset() {
|
||||
*x = ReadRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReadRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ReadRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ReadRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ReadRequest) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ReadRequest) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ReadRequest) GetSize() int64 {
|
||||
if x != nil {
|
||||
return x.Size
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Size int64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Eof bool `protobuf:"varint,3,opt,name=eof,proto3" json:"eof,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReadResponse) Reset() {
|
||||
*x = ReadResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReadResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ReadResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ReadResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ReadResponse) GetSize() int64 {
|
||||
if x != nil {
|
||||
return x.Size
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ReadResponse) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadResponse) GetEof() bool {
|
||||
if x != nil {
|
||||
return x.Eof
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type GetRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
BlockId int64 `protobuf:"varint,2,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetRequest) Reset() {
|
||||
*x = GetRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[8]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *GetRequest) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetRequest) GetBlockId() int64 {
|
||||
if x != nil {
|
||||
return x.BlockId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BlockId int64 `protobuf:"varint,1,opt,name=block_id,json=blockId,proto3" json:"block_id,omitempty"`
|
||||
Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetResponse) Reset() {
|
||||
*x = GetResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[9]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *GetResponse) GetBlockId() int64 {
|
||||
if x != nil {
|
||||
return x.BlockId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetResponse) GetSize() int64 {
|
||||
if x != nil {
|
||||
return x.Size
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetResponse) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type WriteRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *WriteRequest) Reset() {
|
||||
*x = WriteRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *WriteRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*WriteRequest) ProtoMessage() {}
|
||||
|
||||
func (x *WriteRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[10]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use WriteRequest.ProtoReflect.Descriptor instead.
|
||||
func (*WriteRequest) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *WriteRequest) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WriteRequest) GetOffset() int64 {
|
||||
if x != nil {
|
||||
return x.Offset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WriteRequest) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type WriteResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *WriteResponse) Reset() {
|
||||
*x = WriteResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *WriteResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*WriteResponse) ProtoMessage() {}
|
||||
|
||||
func (x *WriteResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_file_proto_file_proto_msgTypes[11]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use WriteResponse.ProtoReflect.Descriptor instead.
|
||||
func (*WriteResponse) Descriptor() ([]byte, []int) {
|
||||
return file_util_file_proto_file_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
var File_util_file_proto_file_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_util_file_proto_file_proto_rawDesc = []byte{
|
||||
0x0a, 0x1a, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f,
|
||||
0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x45, 0x0a,
|
||||
0x0b, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x72, 0x75, 0x6e,
|
||||
0x63, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x72, 0x75, 0x6e,
|
||||
0x63, 0x61, 0x74, 0x65, 0x22, 0x36, 0x0a, 0x0c, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x1e, 0x0a, 0x0c,
|
||||
0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x0f, 0x0a, 0x0d,
|
||||
0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a,
|
||||
0x0b, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x12, 0x23, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65,
|
||||
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x4d, 0x6f, 0x64,
|
||||
0x69, 0x66, 0x69, 0x65, 0x64, 0x22, 0x49, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65,
|
||||
0x22, 0x48, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, 0x66, 0x22, 0x37, 0x0a, 0x0a, 0x47, 0x65,
|
||||
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x49, 0x64, 0x22, 0x50, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x4a, 0x0a, 0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x22, 0x0f, 0x0a, 0x0d, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x32, 0xef, 0x02, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x4f,
|
||||
0x70, 0x65, 0x6e, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x22, 0x00, 0x12, 0x45, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e,
|
||||
0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69,
|
||||
0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x04, 0x52, 0x65, 0x61,
|
||||
0x64, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
|
||||
0x12, 0x48, 0x0a, 0x05, 0x57, 0x72, 0x69, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d,
|
||||
0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x72, 0x69, 0x74,
|
||||
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69,
|
||||
0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x05, 0x43, 0x6c,
|
||||
0x6f, 0x73, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_util_file_proto_file_proto_rawDescOnce sync.Once
|
||||
file_util_file_proto_file_proto_rawDescData = file_util_file_proto_file_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_util_file_proto_file_proto_rawDescGZIP() []byte {
|
||||
file_util_file_proto_file_proto_rawDescOnce.Do(func() {
|
||||
file_util_file_proto_file_proto_rawDescData = protoimpl.X.CompressGZIP(file_util_file_proto_file_proto_rawDescData)
|
||||
})
|
||||
return file_util_file_proto_file_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_util_file_proto_file_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_util_file_proto_file_proto_goTypes = []interface{}{
|
||||
(*OpenRequest)(nil), // 0: go.micro.server.OpenRequest
|
||||
(*OpenResponse)(nil), // 1: go.micro.server.OpenResponse
|
||||
(*CloseRequest)(nil), // 2: go.micro.server.CloseRequest
|
||||
(*CloseResponse)(nil), // 3: go.micro.server.CloseResponse
|
||||
(*StatRequest)(nil), // 4: go.micro.server.StatRequest
|
||||
(*StatResponse)(nil), // 5: go.micro.server.StatResponse
|
||||
(*ReadRequest)(nil), // 6: go.micro.server.ReadRequest
|
||||
(*ReadResponse)(nil), // 7: go.micro.server.ReadResponse
|
||||
(*GetRequest)(nil), // 8: go.micro.server.GetRequest
|
||||
(*GetResponse)(nil), // 9: go.micro.server.GetResponse
|
||||
(*WriteRequest)(nil), // 10: go.micro.server.WriteRequest
|
||||
(*WriteResponse)(nil), // 11: go.micro.server.WriteResponse
|
||||
}
|
||||
var file_util_file_proto_file_proto_depIdxs = []int32{
|
||||
0, // 0: go.micro.server.File.Open:input_type -> go.micro.server.OpenRequest
|
||||
4, // 1: go.micro.server.File.Stat:input_type -> go.micro.server.StatRequest
|
||||
6, // 2: go.micro.server.File.Read:input_type -> go.micro.server.ReadRequest
|
||||
10, // 3: go.micro.server.File.Write:input_type -> go.micro.server.WriteRequest
|
||||
2, // 4: go.micro.server.File.Close:input_type -> go.micro.server.CloseRequest
|
||||
1, // 5: go.micro.server.File.Open:output_type -> go.micro.server.OpenResponse
|
||||
5, // 6: go.micro.server.File.Stat:output_type -> go.micro.server.StatResponse
|
||||
7, // 7: go.micro.server.File.Read:output_type -> go.micro.server.ReadResponse
|
||||
11, // 8: go.micro.server.File.Write:output_type -> go.micro.server.WriteResponse
|
||||
3, // 9: go.micro.server.File.Close:output_type -> go.micro.server.CloseResponse
|
||||
5, // [5:10] is the sub-list for method output_type
|
||||
0, // [0:5] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_util_file_proto_file_proto_init() }
|
||||
func file_util_file_proto_file_proto_init() {
|
||||
if File_util_file_proto_file_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_util_file_proto_file_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*OpenRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*OpenResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CloseRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CloseResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StatRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StatResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ReadRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ReadResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*WriteRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_util_file_proto_file_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*WriteResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_util_file_proto_file_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_util_file_proto_file_proto_goTypes,
|
||||
DependencyIndexes: file_util_file_proto_file_proto_depIdxs,
|
||||
MessageInfos: file_util_file_proto_file_proto_msgTypes,
|
||||
}.Build()
|
||||
File_util_file_proto_file_proto = out.File
|
||||
file_util_file_proto_file_proto_rawDesc = nil
|
||||
file_util_file_proto_file_proto_goTypes = nil
|
||||
file_util_file_proto_file_proto_depIdxs = nil
|
||||
}
|
@@ -1,161 +0,0 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: util/file/proto/file.proto
|
||||
|
||||
package go_micro_server
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/unistack-org/micro/v3/api"
|
||||
client "github.com/unistack-org/micro/v3/client"
|
||||
server "github.com/unistack-org/micro/v3/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for File service
|
||||
|
||||
func NewFileEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for File service
|
||||
|
||||
type FileService interface {
|
||||
Open(ctx context.Context, in *OpenRequest, opts ...client.CallOption) (*OpenResponse, error)
|
||||
Stat(ctx context.Context, in *StatRequest, opts ...client.CallOption) (*StatResponse, error)
|
||||
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
|
||||
Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error)
|
||||
Close(ctx context.Context, in *CloseRequest, opts ...client.CallOption) (*CloseResponse, error)
|
||||
}
|
||||
|
||||
type fileService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFileService(name string, c client.Client) FileService {
|
||||
return &fileService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *fileService) Open(ctx context.Context, in *OpenRequest, opts ...client.CallOption) (*OpenResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "File.Open", in)
|
||||
out := new(OpenResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileService) Stat(ctx context.Context, in *StatRequest, opts ...client.CallOption) (*StatResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "File.Stat", in)
|
||||
out := new(StatResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "File.Read", in)
|
||||
out := new(ReadResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileService) Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "File.Write", in)
|
||||
out := new(WriteResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileService) Close(ctx context.Context, in *CloseRequest, opts ...client.CallOption) (*CloseResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "File.Close", in)
|
||||
out := new(CloseResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for File service
|
||||
|
||||
type FileHandler interface {
|
||||
Open(context.Context, *OpenRequest, *OpenResponse) error
|
||||
Stat(context.Context, *StatRequest, *StatResponse) error
|
||||
Read(context.Context, *ReadRequest, *ReadResponse) error
|
||||
Write(context.Context, *WriteRequest, *WriteResponse) error
|
||||
Close(context.Context, *CloseRequest, *CloseResponse) error
|
||||
}
|
||||
|
||||
func RegisterFileHandler(s server.Server, hdlr FileHandler, opts ...server.HandlerOption) error {
|
||||
type file interface {
|
||||
Open(ctx context.Context, in *OpenRequest, out *OpenResponse) error
|
||||
Stat(ctx context.Context, in *StatRequest, out *StatResponse) error
|
||||
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
|
||||
Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error
|
||||
Close(ctx context.Context, in *CloseRequest, out *CloseResponse) error
|
||||
}
|
||||
type File struct {
|
||||
file
|
||||
}
|
||||
h := &fileHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&File{h}, opts...))
|
||||
}
|
||||
|
||||
type fileHandler struct {
|
||||
FileHandler
|
||||
}
|
||||
|
||||
func (h *fileHandler) Open(ctx context.Context, in *OpenRequest, out *OpenResponse) error {
|
||||
return h.FileHandler.Open(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *fileHandler) Stat(ctx context.Context, in *StatRequest, out *StatResponse) error {
|
||||
return h.FileHandler.Stat(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *fileHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
|
||||
return h.FileHandler.Read(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *fileHandler) Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error {
|
||||
return h.FileHandler.Write(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *fileHandler) Close(ctx context.Context, in *CloseRequest, out *CloseResponse) error {
|
||||
return h.FileHandler.Close(ctx, in, out)
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package go.micro.server;
|
||||
|
||||
service File {
|
||||
rpc Open(OpenRequest) returns(OpenResponse) {};
|
||||
rpc Stat(StatRequest) returns(StatResponse) {};
|
||||
rpc Read(ReadRequest) returns(ReadResponse) {};
|
||||
rpc Write(WriteRequest) returns(WriteResponse) {};
|
||||
rpc Close(CloseRequest) returns(CloseResponse) {};
|
||||
}
|
||||
|
||||
message OpenRequest {
|
||||
string filename = 1;
|
||||
bool truncate = 2;
|
||||
}
|
||||
|
||||
message OpenResponse {
|
||||
int64 id = 1;
|
||||
bool result = 2;
|
||||
}
|
||||
|
||||
message CloseRequest {
|
||||
int64 id = 1;
|
||||
}
|
||||
|
||||
message CloseResponse {
|
||||
}
|
||||
|
||||
message StatRequest {
|
||||
string filename = 1;
|
||||
}
|
||||
|
||||
message StatResponse {
|
||||
string type = 1;
|
||||
int64 size = 2;
|
||||
int64 last_modified = 3;
|
||||
}
|
||||
|
||||
message ReadRequest {
|
||||
int64 id = 1;
|
||||
int64 offset = 2;
|
||||
int64 size = 3;
|
||||
}
|
||||
|
||||
message ReadResponse {
|
||||
int64 size = 1;
|
||||
bytes data = 2;
|
||||
bool eof = 3;
|
||||
}
|
||||
|
||||
message GetRequest {
|
||||
int64 id = 1;
|
||||
int64 block_id = 2;
|
||||
}
|
||||
|
||||
message GetResponse {
|
||||
int64 block_id = 1;
|
||||
int64 size = 2;
|
||||
bytes data = 3;
|
||||
}
|
||||
|
||||
message WriteRequest {
|
||||
int64 id = 1;
|
||||
int64 offset = 2;
|
||||
bytes data = 3;
|
||||
}
|
||||
|
||||
message WriteResponse {}
|
@@ -1,234 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package go_micro_server
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion6
|
||||
|
||||
// FileClient is the client API for File service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type FileClient interface {
|
||||
Open(ctx context.Context, in *OpenRequest, opts ...grpc.CallOption) (*OpenResponse, error)
|
||||
Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error)
|
||||
Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error)
|
||||
Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error)
|
||||
Close(ctx context.Context, in *CloseRequest, opts ...grpc.CallOption) (*CloseResponse, error)
|
||||
}
|
||||
|
||||
type fileClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewFileClient(cc grpc.ClientConnInterface) FileClient {
|
||||
return &fileClient{cc}
|
||||
}
|
||||
|
||||
func (c *fileClient) Open(ctx context.Context, in *OpenRequest, opts ...grpc.CallOption) (*OpenResponse, error) {
|
||||
out := new(OpenResponse)
|
||||
err := c.cc.Invoke(ctx, "/go.micro.server.File/Open", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileClient) Stat(ctx context.Context, in *StatRequest, opts ...grpc.CallOption) (*StatResponse, error) {
|
||||
out := new(StatResponse)
|
||||
err := c.cc.Invoke(ctx, "/go.micro.server.File/Stat", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) {
|
||||
out := new(ReadResponse)
|
||||
err := c.cc.Invoke(ctx, "/go.micro.server.File/Read", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileClient) Write(ctx context.Context, in *WriteRequest, opts ...grpc.CallOption) (*WriteResponse, error) {
|
||||
out := new(WriteResponse)
|
||||
err := c.cc.Invoke(ctx, "/go.micro.server.File/Write", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *fileClient) Close(ctx context.Context, in *CloseRequest, opts ...grpc.CallOption) (*CloseResponse, error) {
|
||||
out := new(CloseResponse)
|
||||
err := c.cc.Invoke(ctx, "/go.micro.server.File/Close", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// FileServer is the server API for File service.
|
||||
// All implementations must embed UnimplementedFileServer
|
||||
// for forward compatibility
|
||||
type FileServer interface {
|
||||
Open(context.Context, *OpenRequest) (*OpenResponse, error)
|
||||
Stat(context.Context, *StatRequest) (*StatResponse, error)
|
||||
Read(context.Context, *ReadRequest) (*ReadResponse, error)
|
||||
Write(context.Context, *WriteRequest) (*WriteResponse, error)
|
||||
Close(context.Context, *CloseRequest) (*CloseResponse, error)
|
||||
mustEmbedUnimplementedFileServer()
|
||||
}
|
||||
|
||||
// UnimplementedFileServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedFileServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedFileServer) Open(context.Context, *OpenRequest) (*OpenResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Open not implemented")
|
||||
}
|
||||
func (*UnimplementedFileServer) Stat(context.Context, *StatRequest) (*StatResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Stat not implemented")
|
||||
}
|
||||
func (*UnimplementedFileServer) Read(context.Context, *ReadRequest) (*ReadResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Read not implemented")
|
||||
}
|
||||
func (*UnimplementedFileServer) Write(context.Context, *WriteRequest) (*WriteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Write not implemented")
|
||||
}
|
||||
func (*UnimplementedFileServer) Close(context.Context, *CloseRequest) (*CloseResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Close not implemented")
|
||||
}
|
||||
func (*UnimplementedFileServer) mustEmbedUnimplementedFileServer() {}
|
||||
|
||||
func RegisterFileServer(s *grpc.Server, srv FileServer) {
|
||||
s.RegisterService(&_File_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _File_Open_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(OpenRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(FileServer).Open(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/go.micro.server.File/Open",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(FileServer).Open(ctx, req.(*OpenRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _File_Stat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StatRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(FileServer).Stat(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/go.micro.server.File/Stat",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(FileServer).Stat(ctx, req.(*StatRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _File_Read_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReadRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(FileServer).Read(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/go.micro.server.File/Read",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(FileServer).Read(ctx, req.(*ReadRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _File_Write_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(WriteRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(FileServer).Write(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/go.micro.server.File/Write",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(FileServer).Write(ctx, req.(*WriteRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _File_Close_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CloseRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(FileServer).Close(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/go.micro.server.File/Close",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(FileServer).Close(ctx, req.(*CloseRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _File_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "go.micro.server.File",
|
||||
HandlerType: (*FileServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Open",
|
||||
Handler: _File_Open_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Stat",
|
||||
Handler: _File_Stat_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Read",
|
||||
Handler: _File_Read_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Write",
|
||||
Handler: _File_Write_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Close",
|
||||
Handler: _File_Close_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "util/file/proto/file.proto",
|
||||
}
|
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/unistack-org/micro/v3/metadata"
|
||||
"github.com/unistack-org/micro/v3/router/registry"
|
||||
"github.com/unistack-org/micro/v3/selector/random"
|
||||
)
|
||||
|
||||
@@ -46,9 +45,7 @@ func WriteInternalServerError(w http.ResponseWriter, err error) {
|
||||
}
|
||||
|
||||
func NewRoundTripper(opts ...Option) http.RoundTripper {
|
||||
options := Options{
|
||||
Router: registry.NewRouter(),
|
||||
}
|
||||
options := Options{}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// +build ignore
|
||||
|
||||
package http
|
||||
|
||||
import (
|
||||
|
@@ -341,16 +341,20 @@ func NewDeployment(name, version, typ, namespace string) *Deployment {
|
||||
|
||||
// NewLocalClient returns a client that can be used with `kubectl proxy`
|
||||
func NewLocalClient(hosts ...string) *client {
|
||||
if len(hosts) == 0 {
|
||||
hosts[0] = "http://localhost:8001"
|
||||
}
|
||||
return &client{
|
||||
c := &client{
|
||||
opts: &api.Options{
|
||||
Client: http.DefaultClient,
|
||||
Host: hosts[0],
|
||||
Namespace: "default",
|
||||
},
|
||||
}
|
||||
|
||||
if len(hosts) == 0 {
|
||||
c.opts.Host = "http://localhost:8001"
|
||||
} else {
|
||||
c.opts.Host = hosts[0]
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClusterClient creates a Kubernetes client for use from within a k8s pod.
|
||||
|
@@ -8,8 +8,9 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// GenerateKey returns an ed25519 key
|
||||
@@ -91,36 +92,36 @@ func Sign(CACrt, CAKey, CSR []byte, opts ...CertOption) ([]byte, error) {
|
||||
}
|
||||
asn1CACrt, err := decodePEM(CACrt)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode CA Crt PEM")
|
||||
return nil, fmt.Errorf("failed to decode CA Crt PEM: %w", err)
|
||||
}
|
||||
if len(asn1CACrt) != 1 {
|
||||
return nil, errors.Errorf("expected 1 CA Crt, got %d", len(asn1CACrt))
|
||||
return nil, fmt.Errorf("expected 1 CA Crt, got %d", len(asn1CACrt))
|
||||
}
|
||||
caCrt, err := x509.ParseCertificate(asn1CACrt[0].Bytes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ca is not a valid certificate")
|
||||
return nil, fmt.Errorf("ca is not a valid certificate: %w", err)
|
||||
}
|
||||
asn1CAKey, err := decodePEM(CAKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode CA Key PEM")
|
||||
return nil, fmt.Errorf("failed to decode CA Key PEM: %w", err)
|
||||
}
|
||||
if len(asn1CAKey) != 1 {
|
||||
return nil, errors.Errorf("expected 1 CA Key, got %d", len(asn1CACrt))
|
||||
return nil, fmt.Errorf("expected 1 CA Key, got %d", len(asn1CACrt))
|
||||
}
|
||||
caKey, err := x509.ParsePKCS8PrivateKey(asn1CAKey[0].Bytes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ca key is not a valid private key")
|
||||
return nil, fmt.Errorf("ca key is not a valid private key: %w", err)
|
||||
}
|
||||
asn1CSR, err := decodePEM(CSR)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode CSR PEM")
|
||||
return nil, fmt.Errorf("failed to decode CSR PEM: %w", err)
|
||||
}
|
||||
if len(asn1CSR) != 1 {
|
||||
return nil, errors.Errorf("expected 1 CSR, got %d", len(asn1CSR))
|
||||
return nil, fmt.Errorf("expected 1 CSR, got %d", len(asn1CSR))
|
||||
}
|
||||
csr, err := x509.ParseCertificateRequest(asn1CSR[0].Bytes)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "csr is invalid")
|
||||
return nil, fmt.Errorf("csr is invalid: %w", err)
|
||||
}
|
||||
template := &x509.Certificate{
|
||||
SignatureAlgorithm: x509.PureEd25519,
|
||||
@@ -137,11 +138,11 @@ func Sign(CACrt, CAKey, CSR []byte, opts ...CertOption) ([]byte, error) {
|
||||
|
||||
x509Cert, err := x509.CreateCertificate(rand.Reader, template, caCrt, caCrt.PublicKey, caKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Couldn't sign certificate")
|
||||
return nil, fmt.Errorf("Couldn't sign certificate: %w", err)
|
||||
}
|
||||
out := &bytes.Buffer{}
|
||||
if err := pem.Encode(out, &pem.Block{Type: "CERTIFICATE", Bytes: x509Cert}); err != nil {
|
||||
return nil, errors.Wrap(err, "couldn't encode cert")
|
||||
return nil, fmt.Errorf("couldn't encode cert: %w", err)
|
||||
}
|
||||
return out.Bytes(), nil
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// +build ignore
|
||||
|
||||
package pool
|
||||
|
||||
import (
|
||||
|
@@ -35,7 +35,7 @@ func TestRemove(t *testing.T) {
|
||||
if i := len(servs); i > 0 {
|
||||
t.Errorf("Expected 0 nodes, got %d: %+v", i, servs)
|
||||
}
|
||||
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
|
||||
if len(os.Getenv("INTEGRATION_TESTS")) == 0 {
|
||||
t.Logf("Services %+v", servs)
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestRemoveNodes(t *testing.T) {
|
||||
if i := len(nodes); i != 1 {
|
||||
t.Errorf("Expected only 1 node, got %d: %+v", i, nodes)
|
||||
}
|
||||
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
|
||||
if len(os.Getenv("INTEGRATION_TESTS")) == 0 {
|
||||
t.Logf("Nodes %+v", nodes)
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/client/mucp"
|
||||
"github.com/unistack-org/micro/v3/codec"
|
||||
"github.com/unistack-org/micro/v3/metadata"
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
@@ -77,12 +76,12 @@ func (s *stream) Error() error {
|
||||
|
||||
// New returns a new encapsulated stream
|
||||
// Proto stream within a server.Stream
|
||||
func New(service, endpoint string, req interface{}, s Stream) server.Stream {
|
||||
func New(service, endpoint string, req interface{}, c client.Client, s Stream) server.Stream {
|
||||
return &stream{
|
||||
Stream: s,
|
||||
request: &request{
|
||||
context: s.Context(),
|
||||
Request: mucp.NewClient().NewRequest(service, endpoint, req),
|
||||
Request: c.NewRequest(service, endpoint, req),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/unistack-org/micro/v3/store"
|
||||
)
|
||||
|
||||
@@ -32,11 +32,11 @@ func (c *syncStore) processQueue(index int) {
|
||||
for i := 0; i < q.Len(); i++ {
|
||||
r, ok := q.PopFront()
|
||||
if !ok {
|
||||
panic(errors.Errorf("retrieved an invalid value from the L%d sync queue", index+1))
|
||||
panic(fmt.Errorf("retrieved an invalid value from the L%d sync queue", index+1))
|
||||
}
|
||||
ir, ok := r.(*internalRecord)
|
||||
if !ok {
|
||||
panic(errors.Errorf("retrieved a non-internal record from the L%d sync queue", index+1))
|
||||
panic(fmt.Errorf("retrieved a non-internal record from the L%d sync queue", index+1))
|
||||
}
|
||||
if !ir.expiresAt.IsZero() && time.Now().After(ir.expiresAt) {
|
||||
continue
|
||||
|
@@ -2,12 +2,12 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ef-ds/deque"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/unistack-org/micro/v3/store"
|
||||
)
|
||||
|
||||
@@ -59,7 +59,7 @@ func (c *syncStore) Init(opts ...store.Option) error {
|
||||
}
|
||||
for _, s := range c.syncOpts.Stores {
|
||||
if err := s.Init(); err != nil {
|
||||
return errors.Wrapf(err, "Store %s failed to Init()", s.String())
|
||||
return fmt.Errorf("Store %s failed to Init(): %w", s.String(), err)
|
||||
}
|
||||
}
|
||||
c.pendingWrites = make([]*deque.Deque, len(c.syncOpts.Stores)-1)
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// +build ignore
|
||||
|
||||
package basic
|
||||
|
||||
import (
|
||||
|
Reference in New Issue
Block a user