Git Product home page Git Product logo

toldata's People

Contributors

herpiko avatar mdamt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

toldata's Issues

Toldata generated unreachable code.

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
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.