citradigital / toldata Goto Github PK
View Code? Open in Web Editor NEWUse protobuf in Nats.io in a simple way
License: Apache License 2.0
Use protobuf in Nats.io in a simple way
License: Apache License 2.0
Proto,
syntax = "proto3";
package xxx.blob;
option go_package = "xxx_blob";
message BlobChunk {
int32 size = 1;
bytes data = 2;
int32 seq = 3;
}
message BlobData {
string id = 1;
string filename = 2;
string content_type = 3;
int64 timestamp = 4;
int64 size = 5;
string metadata = 6;
bool has_content = 8;
bool is_public = 9;
string bucket = 10;
}
message PutResponse {
string id = 1;
}
message GetRequest {
string id = 1;
}
message DeleteRequest {
string id = 1;
string bucket = 2;
}
message UpdateRequest {
string id = 1;
BlobData list = 3;
}
message GetPublicRequest {
string filename = 1;
}
message GetPolicyRequest {
string policy_id = 1;
}
message GetPolicyDocRequest {
string filename = 1;
}
message GetDefaultRequest {
string filename = 1;
}
message GetChunksRequest {
string blob_id = 1;
}
message PutChunksRequest {
string blob_id = 1;
BlobChunk chunk = 2;
}
message ListRequest {
int32 limit = 1;
int32 page = 2;
string order_by = 3;
string order = 4;
string search = 5;
// list of files
int32 total = 6;
repeated BlobData list = 7;
}
message ListResponse {
int32 limit = 1;
int32 page = 2;
string order_by = 3;
string order = 4;
string search = 5;
// list of files
int32 total = 6;
repeated BlobData list = 7;
}
message BucketRequest {
string filename = 1;
string bucket = 2;
}
message Empty {}
service Blob {
rpc Put(BlobData) returns (PutResponse) {}
rpc Get(GetRequest) returns (BlobData) {}
rpc GetFromBucket(BucketRequest) returns (BlobData){}
rpc GetPolicy(GetPolicyRequest) returns (BlobData) {}
rpc GetPolicyDoc(GetPolicyDocRequest) returns (BlobData) {}
rpc GetDefault(GetDefaultRequest) returns (BlobData) {}
rpc GetPublic(GetPublicRequest) returns (BlobData) {}
rpc List(ListRequest) returns (ListResponse) {}
rpc Delete(DeleteRequest) returns (Empty) {}
rpc Update(UpdateRequest) returns (Empty) {}
rpc PutChunks(stream PutChunksRequest) returns (Empty) {}
rpc GetChunks(GetChunksRequest) returns (stream BlobChunk) {}
}
go vet,
# xxx_blob
./blob.grpc.pb.go:211:2: unreachable code
blob.grpc.pb.go
,
// Code generated by github.com/citradigital/toldata. DO NOT EDIT.
// package: xxx.blob
// source: blob.proto
package xxx_blob
import (
"io"
"github.com/citradigital/toldata"
context "golang.org/x/net/context"
)
// Workaround for template problem
func _eof_grpc() error {
return io.EOF
}
type BlobGRPC struct {
Context context.Context
Bus *toldata.Bus
Service *BlobToldataClient
}
func NewBlobGRPC(ctx context.Context, config toldata.ServiceConfiguration) (*BlobGRPC, error) {
client, err := toldata.NewBus(ctx, config)
if err != nil {
return nil, err
}
service := BlobGRPC{
Context: ctx,
Bus: client,
Service: NewBlobToldataClient(client),
}
return &service, nil
}
func (svc *BlobGRPC) Close() {
svc.Bus.Close()
}
func (svc *BlobGRPC) Put(ctx context.Context, req *BlobData) (*PutResponse, error) {
return svc.Service.Put(ctx, req)
}
func (svc *BlobGRPC) Get(ctx context.Context, req *GetRequest) (*BlobData, error) {
return svc.Service.Get(ctx, req)
}
func (svc *BlobGRPC) GetFromBucket(ctx context.Context, req *BucketRequest) (*BlobData, error) {
return svc.Service.GetFromBucket(ctx, req)
}
func (svc *BlobGRPC) GetPolicy(ctx context.Context, req *GetPolicyRequest) (*BlobData, error) {
return svc.Service.GetPolicy(ctx, req)
}
func (svc *BlobGRPC) GetPolicyDoc(ctx context.Context, req *GetPolicyDocRequest) (*BlobData, error) {
return svc.Service.GetPolicyDoc(ctx, req)
}
func (svc *BlobGRPC) GetDefault(ctx context.Context, req *GetDefaultRequest) (*BlobData, error) {
return svc.Service.GetDefault(ctx, req)
}
func (svc *BlobGRPC) GetPublic(ctx context.Context, req *GetPublicRequest) (*BlobData, error) {
return svc.Service.GetPublic(ctx, req)
}
func (svc *BlobGRPC) List(ctx context.Context, req *ListRequest) (*ListResponse, error) {
return svc.Service.List(ctx, req)
}
func (svc *BlobGRPC) Delete(ctx context.Context, req *DeleteRequest) (*Empty, error) {
return svc.Service.Delete(ctx, req)
}
func (svc *BlobGRPC) Update(ctx context.Context, req *UpdateRequest) (*Empty, error) {
return svc.Service.Update(ctx, req)
}
func (svc *BlobGRPC) PutChunks(stream Blob_PutChunksServer) error {
svrStream, err := svc.Service.PutChunks(stream.Context())
if err != nil {
return err
}
for {
isEOF := false
data, err := stream.Recv()
if err != nil {
if err == io.EOF {
isEOF = true
} else {
return err
}
}
if data != nil {
err = svrStream.Send(data)
if err != nil {
return err
}
}
if isEOF {
break
}
}
resp, err := svrStream.Done()
if err != nil {
return err
}
err = stream.SendAndClose(resp)
if err != nil {
return err
}
return nil
}
func (svc *BlobGRPC) GetChunks(req *GetChunksRequest, stream Blob_GetChunksServer) error {
svrStream, err := svc.Service.GetChunks(stream.Context(), req)
if err != nil {
return err
}
for {
data, err := svrStream.Receive()
if err != nil {
return err
}
err = stream.Send(data)
if err != nil {
return err
}
}
return nil
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.