Adding file upload and download capabilities (#1610)
This commit is contained in:
188
util/file/client.go
Normal file
188
util/file/client.go
Normal file
@@ -0,0 +1,188 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
proto "github.com/micro/go-micro/v2/util/file/proto"
|
||||
)
|
||||
|
||||
// Client is the client interface to access files
|
||||
type Client interface {
|
||||
Open(filename string) (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 NewClient(service string, c client.Client) Client {
|
||||
return &fc{proto.NewFileService(service, c)}
|
||||
}
|
||||
|
||||
const (
|
||||
blockSize = 512 * 1024
|
||||
)
|
||||
|
||||
type fc struct {
|
||||
c proto.FileService
|
||||
}
|
||||
|
||||
func (c *fc) Open(filename string) (int64, error) {
|
||||
rsp, err := c.c.Open(context.TODO(), &proto.OpenRequest{Filename: filename})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return rsp.Id, nil
|
||||
}
|
||||
|
||||
func (c *fc) Stat(filename string) (*proto.StatResponse, error) {
|
||||
return c.c.Stat(context.TODO(), &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(context.TODO(), &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(context.TODO(), &proto.WriteRequest{
|
||||
Id: sessionId,
|
||||
Offset: offset,
|
||||
Data: data})
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *fc) Close(sessionId int64) error {
|
||||
_, err := c.c.Close(context.TODO(), &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)
|
||||
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 errors.New(fmt.Sprintf("%s is directory.", filename))
|
||||
}
|
||||
|
||||
blocks := int(stat.Size / blockSize)
|
||||
if stat.Size%blockSize != 0 {
|
||||
blocks += 1
|
||||
}
|
||||
|
||||
log.Printf("Download %s in %d blocks\n", 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)
|
||||
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 {
|
||||
log.Printf("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
}
|
||||
|
||||
if rerr == io.EOF {
|
||||
break
|
||||
}
|
||||
}
|
||||
log.Printf("Download %s completed", filename)
|
||||
|
||||
c.Close(sessionId)
|
||||
|
||||
return nil
|
||||
}
|
150
util/file/handler.go
Normal file
150
util/file/handler.go
Normal file
@@ -0,0 +1,150 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/micro/go-micro/errors"
|
||||
"github.com/micro/go-micro/v2/logger"
|
||||
"github.com/micro/go-micro/v2/server"
|
||||
proto "github.com/micro/go-micro/v2/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)
|
||||
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 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 sessionId=%d, Offset=%d, n=%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)
|
||||
}
|
958
util/file/proto/file.pb.go
Normal file
958
util/file/proto/file.pb.go
Normal file
@@ -0,0 +1,958 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.22.0
|
||||
// protoc v3.6.1
|
||||
// source: micro/go-micro/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"`
|
||||
}
|
||||
|
||||
func (x *OpenRequest) Reset() {
|
||||
*x = OpenRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_micro_go_micro_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_micro_go_micro_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_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *OpenRequest) GetFilename() string {
|
||||
if x != nil {
|
||||
return x.Filename
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_util_file_proto_file_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
var File_micro_go_micro_util_file_proto_file_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_micro_go_micro_util_file_proto_file_proto_rawDesc = []byte{
|
||||
0x0a, 0x29, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x6d, 0x69, 0x63, 0x72, 0x6f,
|
||||
0x2f, 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, 0x29, 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, 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_micro_go_micro_util_file_proto_file_proto_rawDescOnce sync.Once
|
||||
file_micro_go_micro_util_file_proto_file_proto_rawDescData = file_micro_go_micro_util_file_proto_file_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_micro_go_micro_util_file_proto_file_proto_rawDescGZIP() []byte {
|
||||
file_micro_go_micro_util_file_proto_file_proto_rawDescOnce.Do(func() {
|
||||
file_micro_go_micro_util_file_proto_file_proto_rawDescData = protoimpl.X.CompressGZIP(file_micro_go_micro_util_file_proto_file_proto_rawDescData)
|
||||
})
|
||||
return file_micro_go_micro_util_file_proto_file_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_micro_go_micro_util_file_proto_file_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_micro_go_micro_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_micro_go_micro_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_micro_go_micro_util_file_proto_file_proto_init() }
|
||||
func file_micro_go_micro_util_file_proto_file_proto_init() {
|
||||
if File_micro_go_micro_util_file_proto_file_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_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_micro_go_micro_util_file_proto_file_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_micro_go_micro_util_file_proto_file_proto_goTypes,
|
||||
DependencyIndexes: file_micro_go_micro_util_file_proto_file_proto_depIdxs,
|
||||
MessageInfos: file_micro_go_micro_util_file_proto_file_proto_msgTypes,
|
||||
}.Build()
|
||||
File_micro_go_micro_util_file_proto_file_proto = out.File
|
||||
file_micro_go_micro_util_file_proto_file_proto_rawDesc = nil
|
||||
file_micro_go_micro_util_file_proto_file_proto_goTypes = nil
|
||||
file_micro_go_micro_util_file_proto_file_proto_depIdxs = nil
|
||||
}
|
161
util/file/proto/file.pb.micro.go
Normal file
161
util/file/proto/file.pb.micro.go
Normal file
@@ -0,0 +1,161 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: micro/go-micro/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/micro/go-micro/v2/api"
|
||||
client "github.com/micro/go-micro/v2/client"
|
||||
server "github.com/micro/go-micro/v2/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)
|
||||
}
|
68
util/file/proto/file.proto
Normal file
68
util/file/proto/file.proto
Normal file
@@ -0,0 +1,68 @@
|
||||
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;
|
||||
}
|
||||
|
||||
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 {}
|
Reference in New Issue
Block a user