mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
coordinator proto
This commit is contained in:
parent
c95059b4c6
commit
aa5566c010
4 changed files with 1637 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -17,6 +17,7 @@ proto:
|
|||
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. commonfile/fileproto/protos/*.proto
|
||||
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. net/streampool/testservice/protos/*.proto
|
||||
protoc --gogofaster_out=:. net/secureservice/handshake/handshakeproto/protos/*.proto
|
||||
protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. coordinator/coordinatorproto/protos/*.proto
|
||||
|
||||
deps:
|
||||
go mod download
|
||||
|
|
1431
coordinator/coordinatorproto/coordinator.pb.go
Normal file
1431
coordinator/coordinatorproto/coordinator.pb.go
Normal file
File diff suppressed because it is too large
Load diff
153
coordinator/coordinatorproto/coordinator_drpc.pb.go
Normal file
153
coordinator/coordinatorproto/coordinator_drpc.pb.go
Normal file
|
@ -0,0 +1,153 @@
|
|||
// Code generated by protoc-gen-go-drpc. DO NOT EDIT.
|
||||
// protoc-gen-go-drpc version: v0.0.32
|
||||
// source: coordinator/coordinatorproto/protos/coordinator.proto
|
||||
|
||||
package coordinatorproto
|
||||
|
||||
import (
|
||||
bytes "bytes"
|
||||
context "context"
|
||||
errors "errors"
|
||||
jsonpb "github.com/gogo/protobuf/jsonpb"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
drpc "storj.io/drpc"
|
||||
drpcerr "storj.io/drpc/drpcerr"
|
||||
)
|
||||
|
||||
type drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto struct{}
|
||||
|
||||
func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) Marshal(msg drpc.Message) ([]byte, error) {
|
||||
return proto.Marshal(msg.(proto.Message))
|
||||
}
|
||||
|
||||
func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) Unmarshal(buf []byte, msg drpc.Message) error {
|
||||
return proto.Unmarshal(buf, msg.(proto.Message))
|
||||
}
|
||||
|
||||
func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) JSONMarshal(msg drpc.Message) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func (drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error {
|
||||
return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message))
|
||||
}
|
||||
|
||||
type DRPCCoordinatorClient interface {
|
||||
DRPCConn() drpc.Conn
|
||||
|
||||
SpaceSign(ctx context.Context, in *SpaceSignRequest) (*SpaceSignResponse, error)
|
||||
FileLimitCheck(ctx context.Context, in *FileLimitCheckRequest) (*FileLimitCheckResponse, error)
|
||||
}
|
||||
|
||||
type drpcCoordinatorClient struct {
|
||||
cc drpc.Conn
|
||||
}
|
||||
|
||||
func NewDRPCCoordinatorClient(cc drpc.Conn) DRPCCoordinatorClient {
|
||||
return &drpcCoordinatorClient{cc}
|
||||
}
|
||||
|
||||
func (c *drpcCoordinatorClient) DRPCConn() drpc.Conn { return c.cc }
|
||||
|
||||
func (c *drpcCoordinatorClient) SpaceSign(ctx context.Context, in *SpaceSignRequest) (*SpaceSignResponse, error) {
|
||||
out := new(SpaceSignResponse)
|
||||
err := c.cc.Invoke(ctx, "/coordinator.Coordinator/SpaceSign", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, in, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *drpcCoordinatorClient) FileLimitCheck(ctx context.Context, in *FileLimitCheckRequest) (*FileLimitCheckResponse, error) {
|
||||
out := new(FileLimitCheckResponse)
|
||||
err := c.cc.Invoke(ctx, "/coordinator.Coordinator/FileLimitCheck", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}, in, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type DRPCCoordinatorServer interface {
|
||||
SpaceSign(context.Context, *SpaceSignRequest) (*SpaceSignResponse, error)
|
||||
FileLimitCheck(context.Context, *FileLimitCheckRequest) (*FileLimitCheckResponse, error)
|
||||
}
|
||||
|
||||
type DRPCCoordinatorUnimplementedServer struct{}
|
||||
|
||||
func (s *DRPCCoordinatorUnimplementedServer) SpaceSign(context.Context, *SpaceSignRequest) (*SpaceSignResponse, error) {
|
||||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
func (s *DRPCCoordinatorUnimplementedServer) FileLimitCheck(context.Context, *FileLimitCheckRequest) (*FileLimitCheckResponse, error) {
|
||||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
type DRPCCoordinatorDescription struct{}
|
||||
|
||||
func (DRPCCoordinatorDescription) NumMethods() int { return 2 }
|
||||
|
||||
func (DRPCCoordinatorDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
|
||||
switch n {
|
||||
case 0:
|
||||
return "/coordinator.Coordinator/SpaceSign", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{},
|
||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||
return srv.(DRPCCoordinatorServer).
|
||||
SpaceSign(
|
||||
ctx,
|
||||
in1.(*SpaceSignRequest),
|
||||
)
|
||||
}, DRPCCoordinatorServer.SpaceSign, true
|
||||
case 1:
|
||||
return "/coordinator.Coordinator/FileLimitCheck", drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{},
|
||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||
return srv.(DRPCCoordinatorServer).
|
||||
FileLimitCheck(
|
||||
ctx,
|
||||
in1.(*FileLimitCheckRequest),
|
||||
)
|
||||
}, DRPCCoordinatorServer.FileLimitCheck, true
|
||||
default:
|
||||
return "", nil, nil, nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func DRPCRegisterCoordinator(mux drpc.Mux, impl DRPCCoordinatorServer) error {
|
||||
return mux.Register(impl, DRPCCoordinatorDescription{})
|
||||
}
|
||||
|
||||
type DRPCCoordinator_SpaceSignStream interface {
|
||||
drpc.Stream
|
||||
SendAndClose(*SpaceSignResponse) error
|
||||
}
|
||||
|
||||
type drpcCoordinator_SpaceSignStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcCoordinator_SpaceSignStream) SendAndClose(m *SpaceSignResponse) error {
|
||||
if err := x.MsgSend(m, drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return x.CloseSend()
|
||||
}
|
||||
|
||||
type DRPCCoordinator_FileLimitCheckStream interface {
|
||||
drpc.Stream
|
||||
SendAndClose(*FileLimitCheckResponse) error
|
||||
}
|
||||
|
||||
type drpcCoordinator_FileLimitCheckStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcCoordinator_FileLimitCheckStream) SendAndClose(m *FileLimitCheckResponse) error {
|
||||
if err := x.MsgSend(m, drpcEncoding_File_coordinator_coordinatorproto_protos_coordinator_proto{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return x.CloseSend()
|
||||
}
|
52
coordinator/coordinatorproto/protos/coordinator.proto
Normal file
52
coordinator/coordinatorproto/protos/coordinator.proto
Normal file
|
@ -0,0 +1,52 @@
|
|||
syntax = "proto3";
|
||||
package coordinator;
|
||||
|
||||
option go_package = "coordinator/coordinatorproto";
|
||||
|
||||
service Coordinator {
|
||||
// SpaceSign signs a space creation operation
|
||||
rpc SpaceSign(SpaceSignRequest) returns (SpaceSignResponse);
|
||||
|
||||
// FileLimitCheck checks a limit by account and space
|
||||
// can be used only:
|
||||
// - if a handshake identity matches a given identity
|
||||
// - if a requester contains in nodeconf list
|
||||
rpc FileLimitCheck(FileLimitCheckRequest) returns (FileLimitCheckResponse);
|
||||
}
|
||||
|
||||
message SpaceSignRequest {
|
||||
string spaceId = 1;
|
||||
}
|
||||
|
||||
message SpaceSignResponse {
|
||||
SpaceReceiptWithSignature receipt = 1;
|
||||
}
|
||||
|
||||
// SpaceReceiptWithSignature contains protobuf encoded receipt and its signature
|
||||
message SpaceReceiptWithSignature {
|
||||
bytes spaceReceiptPayload = 1;
|
||||
bytes signature = 2;
|
||||
}
|
||||
|
||||
// SpaceReceipt contains permission to SpacePush operation
|
||||
message SpaceReceipt {
|
||||
string spaceId = 1;
|
||||
// identity of space owner
|
||||
bytes accountIdentity = 2;
|
||||
// identity of control node
|
||||
bytes controlNodeIdentity = 3;
|
||||
// unix-timestamp with a deadline time of receipt validity
|
||||
uint64 validUntil = 4;
|
||||
}
|
||||
|
||||
// FileLimitCheckRequest contains an account identity and spaceId
|
||||
// control node checks that identity owns a given space
|
||||
message FileLimitCheckRequest {
|
||||
bytes accountIdentity = 1;
|
||||
string spaceId = 2;
|
||||
}
|
||||
|
||||
// FileLimitCheckResponse returns a current space limit in bytes
|
||||
message FileLimitCheckResponse {
|
||||
uint64 limit = 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue