From 51309d74b5a5fe65680faa43ca861f294d89e7c4 Mon Sep 17 00:00:00 2001 From: Jesko Plitt Date: Mon, 8 May 2023 13:14:12 +0200 Subject: [PATCH] Add lease, peer node and lock apis --- CHANGELOG.md | 6 + LICENSE | 21 ++ Makefile | 16 + README.md | 27 ++ go/go.mod | 16 + go/go.sum | 20 ++ go/syncpb/lease.pb.go | 462 ++++++++++++++++++++++++ go/syncpb/lock.pb.go | 641 ++++++++++++++++++++++++++++++++++ go/syncpb/peer_nodes.pb.go | 205 +++++++++++ go/syncpb/service.pb.go | 135 +++++++ go/syncpb/service_grpc.pb.go | 454 ++++++++++++++++++++++++ nodejs/.gitignore | 7 + nodejs/LICENSE | 21 ++ nodejs/package.json | 35 ++ nodejs/proto.sh | 16 + nodejs/src/index.ts | 24 ++ nodejs/src/sync/lease.ts | 400 +++++++++++++++++++++ nodejs/src/sync/lock.ts | 596 +++++++++++++++++++++++++++++++ nodejs/src/sync/peer_nodes.ts | 144 ++++++++ nodejs/src/sync/service.ts | 224 ++++++++++++ nodejs/tsconfig.json | 26 ++ proto.sh | 14 + sync/lease.proto | 25 ++ sync/lock.proto | 36 ++ sync/peer_nodes.proto | 10 + sync/service.proto | 18 + 26 files changed, 3599 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 go/go.mod create mode 100644 go/go.sum create mode 100644 go/syncpb/lease.pb.go create mode 100644 go/syncpb/lock.pb.go create mode 100644 go/syncpb/peer_nodes.pb.go create mode 100644 go/syncpb/service.pb.go create mode 100644 go/syncpb/service_grpc.pb.go create mode 100644 nodejs/.gitignore create mode 100644 nodejs/LICENSE create mode 100644 nodejs/package.json create mode 100755 nodejs/proto.sh create mode 100644 nodejs/src/index.ts create mode 100644 nodejs/src/sync/lease.ts create mode 100644 nodejs/src/sync/lock.ts create mode 100644 nodejs/src/sync/peer_nodes.ts create mode 100644 nodejs/src/sync/service.ts create mode 100644 nodejs/tsconfig.json create mode 100755 proto.sh create mode 100644 sync/lease.proto create mode 100644 sync/lock.proto create mode 100644 sync/peer_nodes.proto create mode 100644 sync/service.proto diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..920e564 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# v0.0.1 + +- (feature) Lease API +- (feature) Peer node API +- (feature) Local lock API +- (feature) Global lock API diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..47e61d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Becklyn Studios + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..257c77d --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: help +help: ## Show this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"; printf "\Targets:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: proto +proto: ## Generates the code from .proto files + ./proto.sh + cd ./nodejs && npm install && npm run proto + +.PHONY: build +build: ## Builds the nodejs code + cd ./nodejs && npm install && npm run build + +.PHONY: publish-nodejs +publish-nodejs: ## Publishes the nodejs code to the npm registry + cd ./nodejs && npm run np:publish diff --git a/README.md b/README.md new file mode 100644 index 0000000..03aacb4 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# sync-proto + +This repository contains all protocol buffers for the gRPC api of the sync service. + +## Usage + +### Install go package + +```bash +go get -u github.com/fraym/sync-proto/go +``` + +### Install nodejs package + +```bash +npm i @fraym/sync-proto +``` + +## Development + +1. change .proto files +2. run `make proto` +3. ensure that you export all services and requests in `nodejs/src/index.ts` +4. run `make build` +5. adjust CHANGELOG.md and commit all your changes +6. release nodejs code by executing `make publish-nodejs` +7. release go code by creating a new git release with a tag in the form of `go/v1.0.0` (the prefix `go/` is important) diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 0000000..18ad640 --- /dev/null +++ b/go/go.mod @@ -0,0 +1,16 @@ +module github.com/fraym/sync-proto/go + +go 1.20 + +require ( + google.golang.org/grpc v1.55.0 + google.golang.org/protobuf v1.30.0 +) + +require ( + github.com/golang/protobuf v1.5.3 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect +) diff --git a/go/go.sum b/go/go.sum new file mode 100644 index 0000000..dc51440 --- /dev/null +++ b/go/go.sum @@ -0,0 +1,20 @@ +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/go/syncpb/lease.pb.go b/go/syncpb/lease.pb.go new file mode 100644 index 0000000..ada35c2 --- /dev/null +++ b/go/syncpb/lease.pb.go @@ -0,0 +1,462 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: sync/lease.proto + +package syncpb + +import ( + 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) +) + +type CreateLeaseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` + App string `protobuf:"bytes,2,opt,name=app,proto3" json:"app,omitempty"` + Ttl int32 `protobuf:"varint,3,opt,name=ttl,proto3" json:"ttl,omitempty"` +} + +func (x *CreateLeaseRequest) Reset() { + *x = CreateLeaseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateLeaseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateLeaseRequest) ProtoMessage() {} + +func (x *CreateLeaseRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 CreateLeaseRequest.ProtoReflect.Descriptor instead. +func (*CreateLeaseRequest) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateLeaseRequest) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *CreateLeaseRequest) GetApp() string { + if x != nil { + return x.App + } + return "" +} + +func (x *CreateLeaseRequest) GetTtl() int32 { + if x != nil { + return x.Ttl + } + return 0 +} + +type CreateLeaseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` +} + +func (x *CreateLeaseResponse) Reset() { + *x = CreateLeaseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateLeaseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateLeaseResponse) ProtoMessage() {} + +func (x *CreateLeaseResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 CreateLeaseResponse.ProtoReflect.Descriptor instead. +func (*CreateLeaseResponse) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateLeaseResponse) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +type KeepLeaseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` + Ttl int32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"` +} + +func (x *KeepLeaseRequest) Reset() { + *x = KeepLeaseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KeepLeaseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeepLeaseRequest) ProtoMessage() {} + +func (x *KeepLeaseRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 KeepLeaseRequest.ProtoReflect.Descriptor instead. +func (*KeepLeaseRequest) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{2} +} + +func (x *KeepLeaseRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +func (x *KeepLeaseRequest) GetTtl() int32 { + if x != nil { + return x.Ttl + } + return 0 +} + +type KeepLeaseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *KeepLeaseResponse) Reset() { + *x = KeepLeaseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *KeepLeaseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*KeepLeaseResponse) ProtoMessage() {} + +func (x *KeepLeaseResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 KeepLeaseResponse.ProtoReflect.Descriptor instead. +func (*KeepLeaseResponse) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{3} +} + +type DropLeaseRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` +} + +func (x *DropLeaseRequest) Reset() { + *x = DropLeaseRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DropLeaseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DropLeaseRequest) ProtoMessage() {} + +func (x *DropLeaseRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 DropLeaseRequest.ProtoReflect.Descriptor instead. +func (*DropLeaseRequest) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{4} +} + +func (x *DropLeaseRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +type DropLeaseResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DropLeaseResponse) Reset() { + *x = DropLeaseResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lease_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DropLeaseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DropLeaseResponse) ProtoMessage() {} + +func (x *DropLeaseResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lease_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 DropLeaseResponse.ProtoReflect.Descriptor instead. +func (*DropLeaseResponse) Descriptor() ([]byte, []int) { + return file_sync_lease_proto_rawDescGZIP(), []int{5} +} + +var File_sync_lease_proto protoreflect.FileDescriptor + +var file_sync_lease_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x73, 0x79, 0x6e, 0x63, 0x2f, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x04, 0x73, 0x79, 0x6e, 0x63, 0x22, 0x48, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x10, + 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x70, 0x70, + 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, + 0x74, 0x6c, 0x22, 0x2f, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x65, 0x61, 0x73, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x49, 0x64, 0x22, 0x3e, 0x0a, 0x10, 0x4b, 0x65, 0x65, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, + 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x74, 0x74, 0x6c, 0x22, 0x13, 0x0a, 0x11, 0x4b, 0x65, 0x65, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x0a, 0x10, 0x44, 0x72, 0x6f, 0x70, + 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x22, 0x13, 0x0a, 0x11, 0x44, 0x72, 0x6f, 0x70, 0x4c, 0x65, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_sync_lease_proto_rawDescOnce sync.Once + file_sync_lease_proto_rawDescData = file_sync_lease_proto_rawDesc +) + +func file_sync_lease_proto_rawDescGZIP() []byte { + file_sync_lease_proto_rawDescOnce.Do(func() { + file_sync_lease_proto_rawDescData = protoimpl.X.CompressGZIP(file_sync_lease_proto_rawDescData) + }) + return file_sync_lease_proto_rawDescData +} + +var file_sync_lease_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_sync_lease_proto_goTypes = []interface{}{ + (*CreateLeaseRequest)(nil), // 0: sync.CreateLeaseRequest + (*CreateLeaseResponse)(nil), // 1: sync.CreateLeaseResponse + (*KeepLeaseRequest)(nil), // 2: sync.KeepLeaseRequest + (*KeepLeaseResponse)(nil), // 3: sync.KeepLeaseResponse + (*DropLeaseRequest)(nil), // 4: sync.DropLeaseRequest + (*DropLeaseResponse)(nil), // 5: sync.DropLeaseResponse +} +var file_sync_lease_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_sync_lease_proto_init() } +func file_sync_lease_proto_init() { + if File_sync_lease_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_sync_lease_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateLeaseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lease_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateLeaseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lease_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KeepLeaseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lease_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*KeepLeaseResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lease_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DropLeaseRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lease_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DropLeaseResponse); 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_sync_lease_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sync_lease_proto_goTypes, + DependencyIndexes: file_sync_lease_proto_depIdxs, + MessageInfos: file_sync_lease_proto_msgTypes, + }.Build() + File_sync_lease_proto = out.File + file_sync_lease_proto_rawDesc = nil + file_sync_lease_proto_goTypes = nil + file_sync_lease_proto_depIdxs = nil +} diff --git a/go/syncpb/lock.pb.go b/go/syncpb/lock.pb.go new file mode 100644 index 0000000..4192e1e --- /dev/null +++ b/go/syncpb/lock.pb.go @@ -0,0 +1,641 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: sync/lock.proto + +package syncpb + +import ( + 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) +) + +type LocalLockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` + TenantId string `protobuf:"bytes,2,opt,name=tenantId,proto3" json:"tenantId,omitempty"` + GlobalConcern string `protobuf:"bytes,3,opt,name=globalConcern,proto3" json:"globalConcern,omitempty"` + LocalConcern string `protobuf:"bytes,4,opt,name=localConcern,proto3" json:"localConcern,omitempty"` +} + +func (x *LocalLockRequest) Reset() { + *x = LocalLockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LocalLockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LocalLockRequest) ProtoMessage() {} + +func (x *LocalLockRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 LocalLockRequest.ProtoReflect.Descriptor instead. +func (*LocalLockRequest) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{0} +} + +func (x *LocalLockRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +func (x *LocalLockRequest) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *LocalLockRequest) GetGlobalConcern() string { + if x != nil { + return x.GlobalConcern + } + return "" +} + +func (x *LocalLockRequest) GetLocalConcern() string { + if x != nil { + return x.LocalConcern + } + return "" +} + +type LocalLockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LocalLockResponse) Reset() { + *x = LocalLockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LocalLockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LocalLockResponse) ProtoMessage() {} + +func (x *LocalLockResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 LocalLockResponse.ProtoReflect.Descriptor instead. +func (*LocalLockResponse) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{1} +} + +type LocalUnlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` + TenantId string `protobuf:"bytes,2,opt,name=tenantId,proto3" json:"tenantId,omitempty"` + GlobalConcern string `protobuf:"bytes,3,opt,name=globalConcern,proto3" json:"globalConcern,omitempty"` + LocalConcern string `protobuf:"bytes,4,opt,name=localConcern,proto3" json:"localConcern,omitempty"` +} + +func (x *LocalUnlockRequest) Reset() { + *x = LocalUnlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LocalUnlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LocalUnlockRequest) ProtoMessage() {} + +func (x *LocalUnlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 LocalUnlockRequest.ProtoReflect.Descriptor instead. +func (*LocalUnlockRequest) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{2} +} + +func (x *LocalUnlockRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +func (x *LocalUnlockRequest) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *LocalUnlockRequest) GetGlobalConcern() string { + if x != nil { + return x.GlobalConcern + } + return "" +} + +func (x *LocalUnlockRequest) GetLocalConcern() string { + if x != nil { + return x.LocalConcern + } + return "" +} + +type LocalUnlockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *LocalUnlockResponse) Reset() { + *x = LocalUnlockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LocalUnlockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LocalUnlockResponse) ProtoMessage() {} + +func (x *LocalUnlockResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 LocalUnlockResponse.ProtoReflect.Descriptor instead. +func (*LocalUnlockResponse) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{3} +} + +type GlobalLockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` + TenantId string `protobuf:"bytes,2,opt,name=tenantId,proto3" json:"tenantId,omitempty"` + GlobalConcern string `protobuf:"bytes,3,opt,name=globalConcern,proto3" json:"globalConcern,omitempty"` +} + +func (x *GlobalLockRequest) Reset() { + *x = GlobalLockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GlobalLockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GlobalLockRequest) ProtoMessage() {} + +func (x *GlobalLockRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 GlobalLockRequest.ProtoReflect.Descriptor instead. +func (*GlobalLockRequest) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{4} +} + +func (x *GlobalLockRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +func (x *GlobalLockRequest) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *GlobalLockRequest) GetGlobalConcern() string { + if x != nil { + return x.GlobalConcern + } + return "" +} + +type GlobalLockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GlobalLockResponse) Reset() { + *x = GlobalLockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GlobalLockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GlobalLockResponse) ProtoMessage() {} + +func (x *GlobalLockResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 GlobalLockResponse.ProtoReflect.Descriptor instead. +func (*GlobalLockResponse) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{5} +} + +type GlobalUnlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LeaseId string `protobuf:"bytes,1,opt,name=leaseId,proto3" json:"leaseId,omitempty"` + TenantId string `protobuf:"bytes,2,opt,name=tenantId,proto3" json:"tenantId,omitempty"` + GlobalConcern string `protobuf:"bytes,3,opt,name=globalConcern,proto3" json:"globalConcern,omitempty"` +} + +func (x *GlobalUnlockRequest) Reset() { + *x = GlobalUnlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GlobalUnlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GlobalUnlockRequest) ProtoMessage() {} + +func (x *GlobalUnlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 GlobalUnlockRequest.ProtoReflect.Descriptor instead. +func (*GlobalUnlockRequest) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{6} +} + +func (x *GlobalUnlockRequest) GetLeaseId() string { + if x != nil { + return x.LeaseId + } + return "" +} + +func (x *GlobalUnlockRequest) GetTenantId() string { + if x != nil { + return x.TenantId + } + return "" +} + +func (x *GlobalUnlockRequest) GetGlobalConcern() string { + if x != nil { + return x.GlobalConcern + } + return "" +} + +type GlobalUnlockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GlobalUnlockResponse) Reset() { + *x = GlobalUnlockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_lock_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GlobalUnlockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GlobalUnlockResponse) ProtoMessage() {} + +func (x *GlobalUnlockResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_lock_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 GlobalUnlockResponse.ProtoReflect.Descriptor instead. +func (*GlobalUnlockResponse) Descriptor() ([]byte, []int) { + return file_sync_lock_proto_rawDescGZIP(), []int{7} +} + +var File_sync_lock_proto protoreflect.FileDescriptor + +var file_sync_lock_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x73, 0x79, 0x6e, 0x63, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x04, 0x73, 0x79, 0x6e, 0x63, 0x22, 0x92, 0x01, 0x0a, 0x10, 0x4c, 0x6f, 0x63, 0x61, + 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, + 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, + 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, + 0x65, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x6f, 0x63, 0x61, + 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x22, 0x13, 0x0a, 0x11, + 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x94, 0x01, 0x0a, 0x12, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x24, + 0x0a, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, + 0x63, 0x65, 0x72, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x43, 0x6f, 0x6e, + 0x63, 0x65, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6c, 0x6f, 0x63, 0x61, + 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x6f, 0x63, 0x61, + 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x6f, 0x0a, 0x11, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x67, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, + 0x22, 0x14, 0x0a, 0x12, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x71, 0x0a, 0x13, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, + 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, + 0x74, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, + 0x74, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x43, 0x6f, 0x6e, + 0x63, 0x65, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x6c, 0x6f, 0x62, + 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x63, 0x65, 0x72, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x6c, 0x6f, + 0x62, 0x61, 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sync_lock_proto_rawDescOnce sync.Once + file_sync_lock_proto_rawDescData = file_sync_lock_proto_rawDesc +) + +func file_sync_lock_proto_rawDescGZIP() []byte { + file_sync_lock_proto_rawDescOnce.Do(func() { + file_sync_lock_proto_rawDescData = protoimpl.X.CompressGZIP(file_sync_lock_proto_rawDescData) + }) + return file_sync_lock_proto_rawDescData +} + +var file_sync_lock_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_sync_lock_proto_goTypes = []interface{}{ + (*LocalLockRequest)(nil), // 0: sync.LocalLockRequest + (*LocalLockResponse)(nil), // 1: sync.LocalLockResponse + (*LocalUnlockRequest)(nil), // 2: sync.LocalUnlockRequest + (*LocalUnlockResponse)(nil), // 3: sync.LocalUnlockResponse + (*GlobalLockRequest)(nil), // 4: sync.GlobalLockRequest + (*GlobalLockResponse)(nil), // 5: sync.GlobalLockResponse + (*GlobalUnlockRequest)(nil), // 6: sync.GlobalUnlockRequest + (*GlobalUnlockResponse)(nil), // 7: sync.GlobalUnlockResponse +} +var file_sync_lock_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_sync_lock_proto_init() } +func file_sync_lock_proto_init() { + if File_sync_lock_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_sync_lock_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LocalLockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LocalLockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LocalUnlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LocalUnlockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GlobalLockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GlobalLockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GlobalUnlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_lock_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GlobalUnlockResponse); 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_sync_lock_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sync_lock_proto_goTypes, + DependencyIndexes: file_sync_lock_proto_depIdxs, + MessageInfos: file_sync_lock_proto_msgTypes, + }.Build() + File_sync_lock_proto = out.File + file_sync_lock_proto_rawDesc = nil + file_sync_lock_proto_goTypes = nil + file_sync_lock_proto_depIdxs = nil +} diff --git a/go/syncpb/peer_nodes.pb.go b/go/syncpb/peer_nodes.pb.go new file mode 100644 index 0000000..5db7494 --- /dev/null +++ b/go/syncpb/peer_nodes.pb.go @@ -0,0 +1,205 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: sync/peer_nodes.proto + +package syncpb + +import ( + 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) +) + +type GetPeerNodesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + App string `protobuf:"bytes,1,opt,name=app,proto3" json:"app,omitempty"` +} + +func (x *GetPeerNodesRequest) Reset() { + *x = GetPeerNodesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_peer_nodes_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPeerNodesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPeerNodesRequest) ProtoMessage() {} + +func (x *GetPeerNodesRequest) ProtoReflect() protoreflect.Message { + mi := &file_sync_peer_nodes_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 GetPeerNodesRequest.ProtoReflect.Descriptor instead. +func (*GetPeerNodesRequest) Descriptor() ([]byte, []int) { + return file_sync_peer_nodes_proto_rawDescGZIP(), []int{0} +} + +func (x *GetPeerNodesRequest) GetApp() string { + if x != nil { + return x.App + } + return "" +} + +type GetPeerNodesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PeerNodeIp []string `protobuf:"bytes,1,rep,name=peerNodeIp,proto3" json:"peerNodeIp,omitempty"` +} + +func (x *GetPeerNodesResponse) Reset() { + *x = GetPeerNodesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_sync_peer_nodes_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPeerNodesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPeerNodesResponse) ProtoMessage() {} + +func (x *GetPeerNodesResponse) ProtoReflect() protoreflect.Message { + mi := &file_sync_peer_nodes_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 GetPeerNodesResponse.ProtoReflect.Descriptor instead. +func (*GetPeerNodesResponse) Descriptor() ([]byte, []int) { + return file_sync_peer_nodes_proto_rawDescGZIP(), []int{1} +} + +func (x *GetPeerNodesResponse) GetPeerNodeIp() []string { + if x != nil { + return x.PeerNodeIp + } + return nil +} + +var File_sync_peer_nodes_proto protoreflect.FileDescriptor + +var file_sync_peer_nodes_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x73, 0x79, 0x6e, 0x63, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6e, 0x6f, 0x64, 0x65, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x79, 0x6e, 0x63, 0x22, 0x27, 0x0a, + 0x13, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x61, 0x70, 0x70, 0x22, 0x36, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, + 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x70, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x70, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sync_peer_nodes_proto_rawDescOnce sync.Once + file_sync_peer_nodes_proto_rawDescData = file_sync_peer_nodes_proto_rawDesc +) + +func file_sync_peer_nodes_proto_rawDescGZIP() []byte { + file_sync_peer_nodes_proto_rawDescOnce.Do(func() { + file_sync_peer_nodes_proto_rawDescData = protoimpl.X.CompressGZIP(file_sync_peer_nodes_proto_rawDescData) + }) + return file_sync_peer_nodes_proto_rawDescData +} + +var file_sync_peer_nodes_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_sync_peer_nodes_proto_goTypes = []interface{}{ + (*GetPeerNodesRequest)(nil), // 0: sync.GetPeerNodesRequest + (*GetPeerNodesResponse)(nil), // 1: sync.GetPeerNodesResponse +} +var file_sync_peer_nodes_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_sync_peer_nodes_proto_init() } +func file_sync_peer_nodes_proto_init() { + if File_sync_peer_nodes_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_sync_peer_nodes_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetPeerNodesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_sync_peer_nodes_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetPeerNodesResponse); 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_sync_peer_nodes_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sync_peer_nodes_proto_goTypes, + DependencyIndexes: file_sync_peer_nodes_proto_depIdxs, + MessageInfos: file_sync_peer_nodes_proto_msgTypes, + }.Build() + File_sync_peer_nodes_proto = out.File + file_sync_peer_nodes_proto_rawDesc = nil + file_sync_peer_nodes_proto_goTypes = nil + file_sync_peer_nodes_proto_depIdxs = nil +} diff --git a/go/syncpb/service.pb.go b/go/syncpb/service.pb.go new file mode 100644 index 0000000..ad93965 --- /dev/null +++ b/go/syncpb/service.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.12 +// source: sync/service.proto + +package syncpb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +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) +) + +var File_sync_service_proto protoreflect.FileDescriptor + +var file_sync_service_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x73, 0x79, 0x6e, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x79, 0x6e, 0x63, 0x1a, 0x10, 0x73, 0x79, 0x6e, 0x63, + 0x2f, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x73, 0x79, + 0x6e, 0x63, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x73, 0x79, 0x6e, 0x63, 0x2f, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xa6, 0x04, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x46, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x12, + 0x18, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x65, 0x61, + 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x73, 0x79, 0x6e, 0x63, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x40, 0x0a, 0x09, 0x4b, 0x65, 0x65, 0x70, + 0x4c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x4b, 0x65, 0x65, + 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x4b, 0x65, 0x65, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x40, 0x0a, 0x09, 0x44, 0x72, + 0x6f, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x44, + 0x72, 0x6f, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x17, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x4c, 0x65, 0x61, 0x73, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x12, 0x45, 0x0a, 0x0c, + 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x73, + 0x79, 0x6e, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x47, + 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x09, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, + 0x12, 0x16, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, + 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, + 0x12, 0x18, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x55, 0x6e, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x73, 0x79, 0x6e, + 0x63, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, + 0x6f, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x73, + 0x79, 0x6e, 0x63, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, + 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x47, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x79, 0x6e, 0x63, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x55, + 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_sync_service_proto_goTypes = []interface{}{ + (*CreateLeaseRequest)(nil), // 0: sync.CreateLeaseRequest + (*KeepLeaseRequest)(nil), // 1: sync.KeepLeaseRequest + (*DropLeaseRequest)(nil), // 2: sync.DropLeaseRequest + (*GetPeerNodesRequest)(nil), // 3: sync.GetPeerNodesRequest + (*LocalLockRequest)(nil), // 4: sync.LocalLockRequest + (*LocalUnlockRequest)(nil), // 5: sync.LocalUnlockRequest + (*GlobalLockRequest)(nil), // 6: sync.GlobalLockRequest + (*GlobalUnlockRequest)(nil), // 7: sync.GlobalUnlockRequest + (*CreateLeaseResponse)(nil), // 8: sync.CreateLeaseResponse + (*KeepLeaseResponse)(nil), // 9: sync.KeepLeaseResponse + (*DropLeaseResponse)(nil), // 10: sync.DropLeaseResponse + (*GetPeerNodesResponse)(nil), // 11: sync.GetPeerNodesResponse + (*LocalLockResponse)(nil), // 12: sync.LocalLockResponse + (*LocalUnlockResponse)(nil), // 13: sync.LocalUnlockResponse + (*GlobalLockResponse)(nil), // 14: sync.GlobalLockResponse + (*GlobalUnlockResponse)(nil), // 15: sync.GlobalUnlockResponse +} +var file_sync_service_proto_depIdxs = []int32{ + 0, // 0: sync.Service.CreateLease:input_type -> sync.CreateLeaseRequest + 1, // 1: sync.Service.KeepLease:input_type -> sync.KeepLeaseRequest + 2, // 2: sync.Service.DropLease:input_type -> sync.DropLeaseRequest + 3, // 3: sync.Service.GetPeerNodes:input_type -> sync.GetPeerNodesRequest + 4, // 4: sync.Service.LocalLock:input_type -> sync.LocalLockRequest + 5, // 5: sync.Service.LocalUnlock:input_type -> sync.LocalUnlockRequest + 6, // 6: sync.Service.GlobalLock:input_type -> sync.GlobalLockRequest + 7, // 7: sync.Service.GlobalUnlock:input_type -> sync.GlobalUnlockRequest + 8, // 8: sync.Service.CreateLease:output_type -> sync.CreateLeaseResponse + 9, // 9: sync.Service.KeepLease:output_type -> sync.KeepLeaseResponse + 10, // 10: sync.Service.DropLease:output_type -> sync.DropLeaseResponse + 11, // 11: sync.Service.GetPeerNodes:output_type -> sync.GetPeerNodesResponse + 12, // 12: sync.Service.LocalLock:output_type -> sync.LocalLockResponse + 13, // 13: sync.Service.LocalUnlock:output_type -> sync.LocalUnlockResponse + 14, // 14: sync.Service.GlobalLock:output_type -> sync.GlobalLockResponse + 15, // 15: sync.Service.GlobalUnlock:output_type -> sync.GlobalUnlockResponse + 8, // [8:16] is the sub-list for method output_type + 0, // [0:8] 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_sync_service_proto_init() } +func file_sync_service_proto_init() { + if File_sync_service_proto != nil { + return + } + file_sync_lease_proto_init() + file_sync_peer_nodes_proto_init() + file_sync_lock_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_sync_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_sync_service_proto_goTypes, + DependencyIndexes: file_sync_service_proto_depIdxs, + }.Build() + File_sync_service_proto = out.File + file_sync_service_proto_rawDesc = nil + file_sync_service_proto_goTypes = nil + file_sync_service_proto_depIdxs = nil +} diff --git a/go/syncpb/service_grpc.pb.go b/go/syncpb/service_grpc.pb.go new file mode 100644 index 0000000..3e931d8 --- /dev/null +++ b/go/syncpb/service_grpc.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.12 +// source: sync/service.proto + +package syncpb + +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. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ServiceClient is the client API for Service 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 ServiceClient interface { + CreateLease(ctx context.Context, opts ...grpc.CallOption) (Service_CreateLeaseClient, error) + KeepLease(ctx context.Context, opts ...grpc.CallOption) (Service_KeepLeaseClient, error) + DropLease(ctx context.Context, opts ...grpc.CallOption) (Service_DropLeaseClient, error) + GetPeerNodes(ctx context.Context, in *GetPeerNodesRequest, opts ...grpc.CallOption) (*GetPeerNodesResponse, error) + LocalLock(ctx context.Context, in *LocalLockRequest, opts ...grpc.CallOption) (*LocalLockResponse, error) + LocalUnlock(ctx context.Context, in *LocalUnlockRequest, opts ...grpc.CallOption) (*LocalUnlockResponse, error) + GlobalLock(ctx context.Context, in *GlobalLockRequest, opts ...grpc.CallOption) (*GlobalLockResponse, error) + GlobalUnlock(ctx context.Context, in *GlobalUnlockRequest, opts ...grpc.CallOption) (*GlobalUnlockResponse, error) +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) CreateLease(ctx context.Context, opts ...grpc.CallOption) (Service_CreateLeaseClient, error) { + stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[0], "/sync.Service/CreateLease", opts...) + if err != nil { + return nil, err + } + x := &serviceCreateLeaseClient{stream} + return x, nil +} + +type Service_CreateLeaseClient interface { + Send(*CreateLeaseRequest) error + Recv() (*CreateLeaseResponse, error) + grpc.ClientStream +} + +type serviceCreateLeaseClient struct { + grpc.ClientStream +} + +func (x *serviceCreateLeaseClient) Send(m *CreateLeaseRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *serviceCreateLeaseClient) Recv() (*CreateLeaseResponse, error) { + m := new(CreateLeaseResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *serviceClient) KeepLease(ctx context.Context, opts ...grpc.CallOption) (Service_KeepLeaseClient, error) { + stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[1], "/sync.Service/KeepLease", opts...) + if err != nil { + return nil, err + } + x := &serviceKeepLeaseClient{stream} + return x, nil +} + +type Service_KeepLeaseClient interface { + Send(*KeepLeaseRequest) error + Recv() (*KeepLeaseResponse, error) + grpc.ClientStream +} + +type serviceKeepLeaseClient struct { + grpc.ClientStream +} + +func (x *serviceKeepLeaseClient) Send(m *KeepLeaseRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *serviceKeepLeaseClient) Recv() (*KeepLeaseResponse, error) { + m := new(KeepLeaseResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *serviceClient) DropLease(ctx context.Context, opts ...grpc.CallOption) (Service_DropLeaseClient, error) { + stream, err := c.cc.NewStream(ctx, &Service_ServiceDesc.Streams[2], "/sync.Service/DropLease", opts...) + if err != nil { + return nil, err + } + x := &serviceDropLeaseClient{stream} + return x, nil +} + +type Service_DropLeaseClient interface { + Send(*DropLeaseRequest) error + Recv() (*DropLeaseResponse, error) + grpc.ClientStream +} + +type serviceDropLeaseClient struct { + grpc.ClientStream +} + +func (x *serviceDropLeaseClient) Send(m *DropLeaseRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *serviceDropLeaseClient) Recv() (*DropLeaseResponse, error) { + m := new(DropLeaseResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *serviceClient) GetPeerNodes(ctx context.Context, in *GetPeerNodesRequest, opts ...grpc.CallOption) (*GetPeerNodesResponse, error) { + out := new(GetPeerNodesResponse) + err := c.cc.Invoke(ctx, "/sync.Service/GetPeerNodes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) LocalLock(ctx context.Context, in *LocalLockRequest, opts ...grpc.CallOption) (*LocalLockResponse, error) { + out := new(LocalLockResponse) + err := c.cc.Invoke(ctx, "/sync.Service/LocalLock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) LocalUnlock(ctx context.Context, in *LocalUnlockRequest, opts ...grpc.CallOption) (*LocalUnlockResponse, error) { + out := new(LocalUnlockResponse) + err := c.cc.Invoke(ctx, "/sync.Service/LocalUnlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) GlobalLock(ctx context.Context, in *GlobalLockRequest, opts ...grpc.CallOption) (*GlobalLockResponse, error) { + out := new(GlobalLockResponse) + err := c.cc.Invoke(ctx, "/sync.Service/GlobalLock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) GlobalUnlock(ctx context.Context, in *GlobalUnlockRequest, opts ...grpc.CallOption) (*GlobalUnlockResponse, error) { + out := new(GlobalUnlockResponse) + err := c.cc.Invoke(ctx, "/sync.Service/GlobalUnlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +// All implementations must embed UnimplementedServiceServer +// for forward compatibility +type ServiceServer interface { + CreateLease(Service_CreateLeaseServer) error + KeepLease(Service_KeepLeaseServer) error + DropLease(Service_DropLeaseServer) error + GetPeerNodes(context.Context, *GetPeerNodesRequest) (*GetPeerNodesResponse, error) + LocalLock(context.Context, *LocalLockRequest) (*LocalLockResponse, error) + LocalUnlock(context.Context, *LocalUnlockRequest) (*LocalUnlockResponse, error) + GlobalLock(context.Context, *GlobalLockRequest) (*GlobalLockResponse, error) + GlobalUnlock(context.Context, *GlobalUnlockRequest) (*GlobalUnlockResponse, error) + mustEmbedUnimplementedServiceServer() +} + +// UnimplementedServiceServer must be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func (UnimplementedServiceServer) CreateLease(Service_CreateLeaseServer) error { + return status.Errorf(codes.Unimplemented, "method CreateLease not implemented") +} +func (UnimplementedServiceServer) KeepLease(Service_KeepLeaseServer) error { + return status.Errorf(codes.Unimplemented, "method KeepLease not implemented") +} +func (UnimplementedServiceServer) DropLease(Service_DropLeaseServer) error { + return status.Errorf(codes.Unimplemented, "method DropLease not implemented") +} +func (UnimplementedServiceServer) GetPeerNodes(context.Context, *GetPeerNodesRequest) (*GetPeerNodesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPeerNodes not implemented") +} +func (UnimplementedServiceServer) LocalLock(context.Context, *LocalLockRequest) (*LocalLockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LocalLock not implemented") +} +func (UnimplementedServiceServer) LocalUnlock(context.Context, *LocalUnlockRequest) (*LocalUnlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LocalUnlock not implemented") +} +func (UnimplementedServiceServer) GlobalLock(context.Context, *GlobalLockRequest) (*GlobalLockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GlobalLock not implemented") +} +func (UnimplementedServiceServer) GlobalUnlock(context.Context, *GlobalUnlockRequest) (*GlobalUnlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GlobalUnlock not implemented") +} +func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} + +// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ServiceServer will +// result in compilation errors. +type UnsafeServiceServer interface { + mustEmbedUnimplementedServiceServer() +} + +func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) { + s.RegisterService(&Service_ServiceDesc, srv) +} + +func _Service_CreateLease_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ServiceServer).CreateLease(&serviceCreateLeaseServer{stream}) +} + +type Service_CreateLeaseServer interface { + Send(*CreateLeaseResponse) error + Recv() (*CreateLeaseRequest, error) + grpc.ServerStream +} + +type serviceCreateLeaseServer struct { + grpc.ServerStream +} + +func (x *serviceCreateLeaseServer) Send(m *CreateLeaseResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *serviceCreateLeaseServer) Recv() (*CreateLeaseRequest, error) { + m := new(CreateLeaseRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Service_KeepLease_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ServiceServer).KeepLease(&serviceKeepLeaseServer{stream}) +} + +type Service_KeepLeaseServer interface { + Send(*KeepLeaseResponse) error + Recv() (*KeepLeaseRequest, error) + grpc.ServerStream +} + +type serviceKeepLeaseServer struct { + grpc.ServerStream +} + +func (x *serviceKeepLeaseServer) Send(m *KeepLeaseResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *serviceKeepLeaseServer) Recv() (*KeepLeaseRequest, error) { + m := new(KeepLeaseRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Service_DropLease_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ServiceServer).DropLease(&serviceDropLeaseServer{stream}) +} + +type Service_DropLeaseServer interface { + Send(*DropLeaseResponse) error + Recv() (*DropLeaseRequest, error) + grpc.ServerStream +} + +type serviceDropLeaseServer struct { + grpc.ServerStream +} + +func (x *serviceDropLeaseServer) Send(m *DropLeaseResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *serviceDropLeaseServer) Recv() (*DropLeaseRequest, error) { + m := new(DropLeaseRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Service_GetPeerNodes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPeerNodesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).GetPeerNodes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sync.Service/GetPeerNodes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).GetPeerNodes(ctx, req.(*GetPeerNodesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_LocalLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LocalLockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).LocalLock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sync.Service/LocalLock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).LocalLock(ctx, req.(*LocalLockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_LocalUnlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LocalUnlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).LocalUnlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sync.Service/LocalUnlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).LocalUnlock(ctx, req.(*LocalUnlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_GlobalLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GlobalLockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).GlobalLock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sync.Service/GlobalLock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).GlobalLock(ctx, req.(*GlobalLockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_GlobalUnlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GlobalUnlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).GlobalUnlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sync.Service/GlobalUnlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).GlobalUnlock(ctx, req.(*GlobalUnlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Service_ServiceDesc is the grpc.ServiceDesc for Service service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Service_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "sync.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPeerNodes", + Handler: _Service_GetPeerNodes_Handler, + }, + { + MethodName: "LocalLock", + Handler: _Service_LocalLock_Handler, + }, + { + MethodName: "LocalUnlock", + Handler: _Service_LocalUnlock_Handler, + }, + { + MethodName: "GlobalLock", + Handler: _Service_GlobalLock_Handler, + }, + { + MethodName: "GlobalUnlock", + Handler: _Service_GlobalUnlock_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "CreateLease", + Handler: _Service_CreateLease_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "KeepLease", + Handler: _Service_KeepLease_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "DropLease", + Handler: _Service_DropLease_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "sync/service.proto", +} diff --git a/nodejs/.gitignore b/nodejs/.gitignore new file mode 100644 index 0000000..76dfa33 --- /dev/null +++ b/nodejs/.gitignore @@ -0,0 +1,7 @@ +package-lock.json +dist +node_modules +.idea +.test +*.tsbuildinfo +/core diff --git a/nodejs/LICENSE b/nodejs/LICENSE new file mode 100644 index 0000000..47e61d2 --- /dev/null +++ b/nodejs/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Becklyn Studios + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/nodejs/package.json b/nodejs/package.json new file mode 100644 index 0000000..f7c3c35 --- /dev/null +++ b/nodejs/package.json @@ -0,0 +1,35 @@ +{ + "name": "@fraym/sync-proto", + "version": "0.0.1", + "license": "MIT", + "homepage": "https://github.com/fraym/sync-proto", + "repository": { + "type": "git", + "url": "git+https://github.com/fraym/sync-proto.git" + }, + "description": "nodejs generated protobuf code for our sync service", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 0", + "build": "npm run clean && tsc", + "clean": "rm -rf dist", + "np:publish": "np", + "prepublishOnly": "npm run proto && npm run build", + "proto": "./proto.sh" + }, + "files": [ + "dist/**/*" + ], + "main": "dist/index.js", + "types": "dist/index.d.ts", + "dependencies": { + "@grpc/grpc-js": "^1.8.7", + "ts-proto": "^1.129.0" + }, + "devDependencies": { + "@becklyn/prettier": "^1.0.2", + "np": "^7.6.2", + "prettier": "^2.7.1", + "typescript": "^4.8.4" + }, + "prettier": "@becklyn/prettier" +} diff --git a/nodejs/proto.sh b/nodejs/proto.sh new file mode 100755 index 0000000..19301f5 --- /dev/null +++ b/nodejs/proto.sh @@ -0,0 +1,16 @@ +#! /bin/bash +rm -rf ./src/sync + +cd .. + +protoc \ + --plugin=./nodejs/node_modules/.bin/protoc-gen-ts_proto \ + --ts_proto_out=./nodejs/src \ + --ts_proto_opt=esModuleInterop=true \ + --ts_proto_opt=env=node \ + --ts_proto_opt=oneof=unions \ + --ts_proto_opt=outputServices=grpc-js \ + --ts_proto_opt=forceLong=string \ + sync/*.proto + +cd nodejs diff --git a/nodejs/src/index.ts b/nodejs/src/index.ts new file mode 100644 index 0000000..f152d3a --- /dev/null +++ b/nodejs/src/index.ts @@ -0,0 +1,24 @@ +export { ServiceClient, ServiceServer, ServiceService } from "./sync/service"; + +export { + DeepPartial, + CreateLeaseRequest, + CreateLeaseResponse, + DropLeaseRequest, + DropLeaseResponse, + KeepLeaseRequest, + KeepLeaseResponse, +} from "./sync/lease"; + +export { GetPeerNodesRequest, GetPeerNodesResponse } from "./sync/peer_nodes"; + +export { + GlobalLockRequest, + GlobalLockResponse, + GlobalUnlockRequest, + GlobalUnlockResponse, + LocalLockRequest, + LocalLockResponse, + LocalUnlockRequest, + LocalUnlockResponse, +} from "./sync/lock"; diff --git a/nodejs/src/sync/lease.ts b/nodejs/src/sync/lease.ts new file mode 100644 index 0000000..51f05b2 --- /dev/null +++ b/nodejs/src/sync/lease.ts @@ -0,0 +1,400 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "sync"; + +export interface CreateLeaseRequest { + ip: string; + app: string; + ttl: number; +} + +export interface CreateLeaseResponse { + leaseId: string; +} + +export interface KeepLeaseRequest { + leaseId: string; + ttl: number; +} + +export interface KeepLeaseResponse { +} + +export interface DropLeaseRequest { + leaseId: string; +} + +export interface DropLeaseResponse { +} + +function createBaseCreateLeaseRequest(): CreateLeaseRequest { + return { ip: "", app: "", ttl: 0 }; +} + +export const CreateLeaseRequest = { + encode(message: CreateLeaseRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.ip !== "") { + writer.uint32(10).string(message.ip); + } + if (message.app !== "") { + writer.uint32(18).string(message.app); + } + if (message.ttl !== 0) { + writer.uint32(24).int32(message.ttl); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CreateLeaseRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateLeaseRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.ip = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.app = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.ttl = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CreateLeaseRequest { + return { + ip: isSet(object.ip) ? String(object.ip) : "", + app: isSet(object.app) ? String(object.app) : "", + ttl: isSet(object.ttl) ? Number(object.ttl) : 0, + }; + }, + + toJSON(message: CreateLeaseRequest): unknown { + const obj: any = {}; + message.ip !== undefined && (obj.ip = message.ip); + message.app !== undefined && (obj.app = message.app); + message.ttl !== undefined && (obj.ttl = Math.round(message.ttl)); + return obj; + }, + + create, I>>(base?: I): CreateLeaseRequest { + return CreateLeaseRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): CreateLeaseRequest { + const message = createBaseCreateLeaseRequest(); + message.ip = object.ip ?? ""; + message.app = object.app ?? ""; + message.ttl = object.ttl ?? 0; + return message; + }, +}; + +function createBaseCreateLeaseResponse(): CreateLeaseResponse { + return { leaseId: "" }; +} + +export const CreateLeaseResponse = { + encode(message: CreateLeaseResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CreateLeaseResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CreateLeaseResponse { + return { leaseId: isSet(object.leaseId) ? String(object.leaseId) : "" }; + }, + + toJSON(message: CreateLeaseResponse): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + return obj; + }, + + create, I>>(base?: I): CreateLeaseResponse { + return CreateLeaseResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): CreateLeaseResponse { + const message = createBaseCreateLeaseResponse(); + message.leaseId = object.leaseId ?? ""; + return message; + }, +}; + +function createBaseKeepLeaseRequest(): KeepLeaseRequest { + return { leaseId: "", ttl: 0 }; +} + +export const KeepLeaseRequest = { + encode(message: KeepLeaseRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + if (message.ttl !== 0) { + writer.uint32(16).int32(message.ttl); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): KeepLeaseRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseKeepLeaseRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.ttl = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): KeepLeaseRequest { + return { + leaseId: isSet(object.leaseId) ? String(object.leaseId) : "", + ttl: isSet(object.ttl) ? Number(object.ttl) : 0, + }; + }, + + toJSON(message: KeepLeaseRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + message.ttl !== undefined && (obj.ttl = Math.round(message.ttl)); + return obj; + }, + + create, I>>(base?: I): KeepLeaseRequest { + return KeepLeaseRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): KeepLeaseRequest { + const message = createBaseKeepLeaseRequest(); + message.leaseId = object.leaseId ?? ""; + message.ttl = object.ttl ?? 0; + return message; + }, +}; + +function createBaseKeepLeaseResponse(): KeepLeaseResponse { + return {}; +} + +export const KeepLeaseResponse = { + encode(_: KeepLeaseResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): KeepLeaseResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseKeepLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): KeepLeaseResponse { + return {}; + }, + + toJSON(_: KeepLeaseResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): KeepLeaseResponse { + return KeepLeaseResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): KeepLeaseResponse { + const message = createBaseKeepLeaseResponse(); + return message; + }, +}; + +function createBaseDropLeaseRequest(): DropLeaseRequest { + return { leaseId: "" }; +} + +export const DropLeaseRequest = { + encode(message: DropLeaseRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DropLeaseRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDropLeaseRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DropLeaseRequest { + return { leaseId: isSet(object.leaseId) ? String(object.leaseId) : "" }; + }, + + toJSON(message: DropLeaseRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + return obj; + }, + + create, I>>(base?: I): DropLeaseRequest { + return DropLeaseRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): DropLeaseRequest { + const message = createBaseDropLeaseRequest(); + message.leaseId = object.leaseId ?? ""; + return message; + }, +}; + +function createBaseDropLeaseResponse(): DropLeaseResponse { + return {}; +} + +export const DropLeaseResponse = { + encode(_: DropLeaseResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DropLeaseResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDropLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): DropLeaseResponse { + return {}; + }, + + toJSON(_: DropLeaseResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): DropLeaseResponse { + return DropLeaseResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): DropLeaseResponse { + const message = createBaseDropLeaseResponse(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/nodejs/src/sync/lock.ts b/nodejs/src/sync/lock.ts new file mode 100644 index 0000000..3ad0dd5 --- /dev/null +++ b/nodejs/src/sync/lock.ts @@ -0,0 +1,596 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "sync"; + +export interface LocalLockRequest { + leaseId: string; + tenantId: string; + globalConcern: string; + localConcern: string; +} + +export interface LocalLockResponse { +} + +export interface LocalUnlockRequest { + leaseId: string; + tenantId: string; + globalConcern: string; + localConcern: string; +} + +export interface LocalUnlockResponse { +} + +export interface GlobalLockRequest { + leaseId: string; + tenantId: string; + globalConcern: string; +} + +export interface GlobalLockResponse { +} + +export interface GlobalUnlockRequest { + leaseId: string; + tenantId: string; + globalConcern: string; +} + +export interface GlobalUnlockResponse { +} + +function createBaseLocalLockRequest(): LocalLockRequest { + return { leaseId: "", tenantId: "", globalConcern: "", localConcern: "" }; +} + +export const LocalLockRequest = { + encode(message: LocalLockRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + if (message.tenantId !== "") { + writer.uint32(18).string(message.tenantId); + } + if (message.globalConcern !== "") { + writer.uint32(26).string(message.globalConcern); + } + if (message.localConcern !== "") { + writer.uint32(34).string(message.localConcern); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): LocalLockRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLocalLockRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.tenantId = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.globalConcern = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.localConcern = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): LocalLockRequest { + return { + leaseId: isSet(object.leaseId) ? String(object.leaseId) : "", + tenantId: isSet(object.tenantId) ? String(object.tenantId) : "", + globalConcern: isSet(object.globalConcern) ? String(object.globalConcern) : "", + localConcern: isSet(object.localConcern) ? String(object.localConcern) : "", + }; + }, + + toJSON(message: LocalLockRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + message.tenantId !== undefined && (obj.tenantId = message.tenantId); + message.globalConcern !== undefined && (obj.globalConcern = message.globalConcern); + message.localConcern !== undefined && (obj.localConcern = message.localConcern); + return obj; + }, + + create, I>>(base?: I): LocalLockRequest { + return LocalLockRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): LocalLockRequest { + const message = createBaseLocalLockRequest(); + message.leaseId = object.leaseId ?? ""; + message.tenantId = object.tenantId ?? ""; + message.globalConcern = object.globalConcern ?? ""; + message.localConcern = object.localConcern ?? ""; + return message; + }, +}; + +function createBaseLocalLockResponse(): LocalLockResponse { + return {}; +} + +export const LocalLockResponse = { + encode(_: LocalLockResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): LocalLockResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLocalLockResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): LocalLockResponse { + return {}; + }, + + toJSON(_: LocalLockResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): LocalLockResponse { + return LocalLockResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): LocalLockResponse { + const message = createBaseLocalLockResponse(); + return message; + }, +}; + +function createBaseLocalUnlockRequest(): LocalUnlockRequest { + return { leaseId: "", tenantId: "", globalConcern: "", localConcern: "" }; +} + +export const LocalUnlockRequest = { + encode(message: LocalUnlockRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + if (message.tenantId !== "") { + writer.uint32(18).string(message.tenantId); + } + if (message.globalConcern !== "") { + writer.uint32(26).string(message.globalConcern); + } + if (message.localConcern !== "") { + writer.uint32(34).string(message.localConcern); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): LocalUnlockRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLocalUnlockRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.tenantId = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.globalConcern = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.localConcern = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): LocalUnlockRequest { + return { + leaseId: isSet(object.leaseId) ? String(object.leaseId) : "", + tenantId: isSet(object.tenantId) ? String(object.tenantId) : "", + globalConcern: isSet(object.globalConcern) ? String(object.globalConcern) : "", + localConcern: isSet(object.localConcern) ? String(object.localConcern) : "", + }; + }, + + toJSON(message: LocalUnlockRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + message.tenantId !== undefined && (obj.tenantId = message.tenantId); + message.globalConcern !== undefined && (obj.globalConcern = message.globalConcern); + message.localConcern !== undefined && (obj.localConcern = message.localConcern); + return obj; + }, + + create, I>>(base?: I): LocalUnlockRequest { + return LocalUnlockRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): LocalUnlockRequest { + const message = createBaseLocalUnlockRequest(); + message.leaseId = object.leaseId ?? ""; + message.tenantId = object.tenantId ?? ""; + message.globalConcern = object.globalConcern ?? ""; + message.localConcern = object.localConcern ?? ""; + return message; + }, +}; + +function createBaseLocalUnlockResponse(): LocalUnlockResponse { + return {}; +} + +export const LocalUnlockResponse = { + encode(_: LocalUnlockResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): LocalUnlockResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLocalUnlockResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): LocalUnlockResponse { + return {}; + }, + + toJSON(_: LocalUnlockResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): LocalUnlockResponse { + return LocalUnlockResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): LocalUnlockResponse { + const message = createBaseLocalUnlockResponse(); + return message; + }, +}; + +function createBaseGlobalLockRequest(): GlobalLockRequest { + return { leaseId: "", tenantId: "", globalConcern: "" }; +} + +export const GlobalLockRequest = { + encode(message: GlobalLockRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + if (message.tenantId !== "") { + writer.uint32(18).string(message.tenantId); + } + if (message.globalConcern !== "") { + writer.uint32(26).string(message.globalConcern); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GlobalLockRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGlobalLockRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.tenantId = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.globalConcern = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GlobalLockRequest { + return { + leaseId: isSet(object.leaseId) ? String(object.leaseId) : "", + tenantId: isSet(object.tenantId) ? String(object.tenantId) : "", + globalConcern: isSet(object.globalConcern) ? String(object.globalConcern) : "", + }; + }, + + toJSON(message: GlobalLockRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + message.tenantId !== undefined && (obj.tenantId = message.tenantId); + message.globalConcern !== undefined && (obj.globalConcern = message.globalConcern); + return obj; + }, + + create, I>>(base?: I): GlobalLockRequest { + return GlobalLockRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): GlobalLockRequest { + const message = createBaseGlobalLockRequest(); + message.leaseId = object.leaseId ?? ""; + message.tenantId = object.tenantId ?? ""; + message.globalConcern = object.globalConcern ?? ""; + return message; + }, +}; + +function createBaseGlobalLockResponse(): GlobalLockResponse { + return {}; +} + +export const GlobalLockResponse = { + encode(_: GlobalLockResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GlobalLockResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGlobalLockResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): GlobalLockResponse { + return {}; + }, + + toJSON(_: GlobalLockResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): GlobalLockResponse { + return GlobalLockResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): GlobalLockResponse { + const message = createBaseGlobalLockResponse(); + return message; + }, +}; + +function createBaseGlobalUnlockRequest(): GlobalUnlockRequest { + return { leaseId: "", tenantId: "", globalConcern: "" }; +} + +export const GlobalUnlockRequest = { + encode(message: GlobalUnlockRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.leaseId !== "") { + writer.uint32(10).string(message.leaseId); + } + if (message.tenantId !== "") { + writer.uint32(18).string(message.tenantId); + } + if (message.globalConcern !== "") { + writer.uint32(26).string(message.globalConcern); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GlobalUnlockRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGlobalUnlockRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.leaseId = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.tenantId = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.globalConcern = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GlobalUnlockRequest { + return { + leaseId: isSet(object.leaseId) ? String(object.leaseId) : "", + tenantId: isSet(object.tenantId) ? String(object.tenantId) : "", + globalConcern: isSet(object.globalConcern) ? String(object.globalConcern) : "", + }; + }, + + toJSON(message: GlobalUnlockRequest): unknown { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId); + message.tenantId !== undefined && (obj.tenantId = message.tenantId); + message.globalConcern !== undefined && (obj.globalConcern = message.globalConcern); + return obj; + }, + + create, I>>(base?: I): GlobalUnlockRequest { + return GlobalUnlockRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): GlobalUnlockRequest { + const message = createBaseGlobalUnlockRequest(); + message.leaseId = object.leaseId ?? ""; + message.tenantId = object.tenantId ?? ""; + message.globalConcern = object.globalConcern ?? ""; + return message; + }, +}; + +function createBaseGlobalUnlockResponse(): GlobalUnlockResponse { + return {}; +} + +export const GlobalUnlockResponse = { + encode(_: GlobalUnlockResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GlobalUnlockResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGlobalUnlockResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): GlobalUnlockResponse { + return {}; + }, + + toJSON(_: GlobalUnlockResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): GlobalUnlockResponse { + return GlobalUnlockResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(_: I): GlobalUnlockResponse { + const message = createBaseGlobalUnlockResponse(); + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/nodejs/src/sync/peer_nodes.ts b/nodejs/src/sync/peer_nodes.ts new file mode 100644 index 0000000..1a933ab --- /dev/null +++ b/nodejs/src/sync/peer_nodes.ts @@ -0,0 +1,144 @@ +/* eslint-disable */ +import _m0 from "protobufjs/minimal"; + +export const protobufPackage = "sync"; + +export interface GetPeerNodesRequest { + app: string; +} + +export interface GetPeerNodesResponse { + peerNodeIp: string[]; +} + +function createBaseGetPeerNodesRequest(): GetPeerNodesRequest { + return { app: "" }; +} + +export const GetPeerNodesRequest = { + encode(message: GetPeerNodesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.app !== "") { + writer.uint32(10).string(message.app); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetPeerNodesRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetPeerNodesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.app = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GetPeerNodesRequest { + return { app: isSet(object.app) ? String(object.app) : "" }; + }, + + toJSON(message: GetPeerNodesRequest): unknown { + const obj: any = {}; + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + create, I>>(base?: I): GetPeerNodesRequest { + return GetPeerNodesRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): GetPeerNodesRequest { + const message = createBaseGetPeerNodesRequest(); + message.app = object.app ?? ""; + return message; + }, +}; + +function createBaseGetPeerNodesResponse(): GetPeerNodesResponse { + return { peerNodeIp: [] }; +} + +export const GetPeerNodesResponse = { + encode(message: GetPeerNodesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.peerNodeIp) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetPeerNodesResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetPeerNodesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.peerNodeIp.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GetPeerNodesResponse { + return { peerNodeIp: Array.isArray(object?.peerNodeIp) ? object.peerNodeIp.map((e: any) => String(e)) : [] }; + }, + + toJSON(message: GetPeerNodesResponse): unknown { + const obj: any = {}; + if (message.peerNodeIp) { + obj.peerNodeIp = message.peerNodeIp.map((e) => e); + } else { + obj.peerNodeIp = []; + } + return obj; + }, + + create, I>>(base?: I): GetPeerNodesResponse { + return GetPeerNodesResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): GetPeerNodesResponse { + const message = createBaseGetPeerNodesResponse(); + message.peerNodeIp = object.peerNodeIp?.map((e) => e) || []; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/nodejs/src/sync/service.ts b/nodejs/src/sync/service.ts new file mode 100644 index 0000000..59e78d3 --- /dev/null +++ b/nodejs/src/sync/service.ts @@ -0,0 +1,224 @@ +/* eslint-disable */ +import { + CallOptions, + ChannelCredentials, + Client, + ClientDuplexStream, + ClientOptions, + ClientUnaryCall, + handleBidiStreamingCall, + handleUnaryCall, + makeGenericClientConstructor, + Metadata, + ServiceError, + UntypedServiceImplementation, +} from "@grpc/grpc-js"; +import { + CreateLeaseRequest, + CreateLeaseResponse, + DropLeaseRequest, + DropLeaseResponse, + KeepLeaseRequest, + KeepLeaseResponse, +} from "./lease"; +import { + GlobalLockRequest, + GlobalLockResponse, + GlobalUnlockRequest, + GlobalUnlockResponse, + LocalLockRequest, + LocalLockResponse, + LocalUnlockRequest, + LocalUnlockResponse, +} from "./lock"; +import { GetPeerNodesRequest, GetPeerNodesResponse } from "./peer_nodes"; + +export const protobufPackage = "sync"; + +export type ServiceService = typeof ServiceService; +export const ServiceService = { + createLease: { + path: "/sync.Service/CreateLease", + requestStream: true, + responseStream: true, + requestSerialize: (value: CreateLeaseRequest) => Buffer.from(CreateLeaseRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => CreateLeaseRequest.decode(value), + responseSerialize: (value: CreateLeaseResponse) => Buffer.from(CreateLeaseResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => CreateLeaseResponse.decode(value), + }, + keepLease: { + path: "/sync.Service/KeepLease", + requestStream: true, + responseStream: true, + requestSerialize: (value: KeepLeaseRequest) => Buffer.from(KeepLeaseRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => KeepLeaseRequest.decode(value), + responseSerialize: (value: KeepLeaseResponse) => Buffer.from(KeepLeaseResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => KeepLeaseResponse.decode(value), + }, + dropLease: { + path: "/sync.Service/DropLease", + requestStream: true, + responseStream: true, + requestSerialize: (value: DropLeaseRequest) => Buffer.from(DropLeaseRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => DropLeaseRequest.decode(value), + responseSerialize: (value: DropLeaseResponse) => Buffer.from(DropLeaseResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => DropLeaseResponse.decode(value), + }, + getPeerNodes: { + path: "/sync.Service/GetPeerNodes", + requestStream: false, + responseStream: false, + requestSerialize: (value: GetPeerNodesRequest) => Buffer.from(GetPeerNodesRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => GetPeerNodesRequest.decode(value), + responseSerialize: (value: GetPeerNodesResponse) => Buffer.from(GetPeerNodesResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => GetPeerNodesResponse.decode(value), + }, + localLock: { + path: "/sync.Service/LocalLock", + requestStream: false, + responseStream: false, + requestSerialize: (value: LocalLockRequest) => Buffer.from(LocalLockRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => LocalLockRequest.decode(value), + responseSerialize: (value: LocalLockResponse) => Buffer.from(LocalLockResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => LocalLockResponse.decode(value), + }, + localUnlock: { + path: "/sync.Service/LocalUnlock", + requestStream: false, + responseStream: false, + requestSerialize: (value: LocalUnlockRequest) => Buffer.from(LocalUnlockRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => LocalUnlockRequest.decode(value), + responseSerialize: (value: LocalUnlockResponse) => Buffer.from(LocalUnlockResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => LocalUnlockResponse.decode(value), + }, + globalLock: { + path: "/sync.Service/GlobalLock", + requestStream: false, + responseStream: false, + requestSerialize: (value: GlobalLockRequest) => Buffer.from(GlobalLockRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => GlobalLockRequest.decode(value), + responseSerialize: (value: GlobalLockResponse) => Buffer.from(GlobalLockResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => GlobalLockResponse.decode(value), + }, + globalUnlock: { + path: "/sync.Service/GlobalUnlock", + requestStream: false, + responseStream: false, + requestSerialize: (value: GlobalUnlockRequest) => Buffer.from(GlobalUnlockRequest.encode(value).finish()), + requestDeserialize: (value: Buffer) => GlobalUnlockRequest.decode(value), + responseSerialize: (value: GlobalUnlockResponse) => Buffer.from(GlobalUnlockResponse.encode(value).finish()), + responseDeserialize: (value: Buffer) => GlobalUnlockResponse.decode(value), + }, +} as const; + +export interface ServiceServer extends UntypedServiceImplementation { + createLease: handleBidiStreamingCall; + keepLease: handleBidiStreamingCall; + dropLease: handleBidiStreamingCall; + getPeerNodes: handleUnaryCall; + localLock: handleUnaryCall; + localUnlock: handleUnaryCall; + globalLock: handleUnaryCall; + globalUnlock: handleUnaryCall; +} + +export interface ServiceClient extends Client { + createLease(): ClientDuplexStream; + createLease(options: Partial): ClientDuplexStream; + createLease( + metadata: Metadata, + options?: Partial, + ): ClientDuplexStream; + keepLease(): ClientDuplexStream; + keepLease(options: Partial): ClientDuplexStream; + keepLease( + metadata: Metadata, + options?: Partial, + ): ClientDuplexStream; + dropLease(): ClientDuplexStream; + dropLease(options: Partial): ClientDuplexStream; + dropLease( + metadata: Metadata, + options?: Partial, + ): ClientDuplexStream; + getPeerNodes( + request: GetPeerNodesRequest, + callback: (error: ServiceError | null, response: GetPeerNodesResponse) => void, + ): ClientUnaryCall; + getPeerNodes( + request: GetPeerNodesRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: GetPeerNodesResponse) => void, + ): ClientUnaryCall; + getPeerNodes( + request: GetPeerNodesRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: GetPeerNodesResponse) => void, + ): ClientUnaryCall; + localLock( + request: LocalLockRequest, + callback: (error: ServiceError | null, response: LocalLockResponse) => void, + ): ClientUnaryCall; + localLock( + request: LocalLockRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: LocalLockResponse) => void, + ): ClientUnaryCall; + localLock( + request: LocalLockRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: LocalLockResponse) => void, + ): ClientUnaryCall; + localUnlock( + request: LocalUnlockRequest, + callback: (error: ServiceError | null, response: LocalUnlockResponse) => void, + ): ClientUnaryCall; + localUnlock( + request: LocalUnlockRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: LocalUnlockResponse) => void, + ): ClientUnaryCall; + localUnlock( + request: LocalUnlockRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: LocalUnlockResponse) => void, + ): ClientUnaryCall; + globalLock( + request: GlobalLockRequest, + callback: (error: ServiceError | null, response: GlobalLockResponse) => void, + ): ClientUnaryCall; + globalLock( + request: GlobalLockRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: GlobalLockResponse) => void, + ): ClientUnaryCall; + globalLock( + request: GlobalLockRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: GlobalLockResponse) => void, + ): ClientUnaryCall; + globalUnlock( + request: GlobalUnlockRequest, + callback: (error: ServiceError | null, response: GlobalUnlockResponse) => void, + ): ClientUnaryCall; + globalUnlock( + request: GlobalUnlockRequest, + metadata: Metadata, + callback: (error: ServiceError | null, response: GlobalUnlockResponse) => void, + ): ClientUnaryCall; + globalUnlock( + request: GlobalUnlockRequest, + metadata: Metadata, + options: Partial, + callback: (error: ServiceError | null, response: GlobalUnlockResponse) => void, + ): ClientUnaryCall; +} + +export const ServiceClient = makeGenericClientConstructor(ServiceService, "sync.Service") as unknown as { + new (address: string, credentials: ChannelCredentials, options?: Partial): ServiceClient; + service: typeof ServiceService; +}; diff --git a/nodejs/tsconfig.json b/nodejs/tsconfig.json new file mode 100644 index 0000000..d73a4a0 --- /dev/null +++ b/nodejs/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es2017", + "skipLibCheck": true, + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "outDir": "./dist", + "baseUrl": "src", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "moduleResolution": "node", + "lib": ["es2017"] + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/proto.sh b/proto.sh new file mode 100755 index 0000000..b695b17 --- /dev/null +++ b/proto.sh @@ -0,0 +1,14 @@ +#! /bin/bash +for filename in ./sync/*.proto; do + params="$params --go_opt=Msync/$(basename $filename)=github.com/fraym/sync-proto/go/syncpb" + params="$params --go-grpc_opt=Msync/$(basename $filename)=github.com/fraym/sync-proto/go/syncpb" +done + +protoc \ + --proto_path=./ \ + --go_out=./go/ \ + --go-grpc_out=./go/ \ + ${params[@]} \ + --go_opt=module=github.com/fraym/sync-proto/go \ + --go-grpc_opt=module=github.com/fraym/sync-proto/go \ + **/*.proto diff --git a/sync/lease.proto b/sync/lease.proto new file mode 100644 index 0000000..ba41f63 --- /dev/null +++ b/sync/lease.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package sync; + +message CreateLeaseRequest { + string ip = 1; + string app = 2; + int32 ttl = 3; +} + +message CreateLeaseResponse { + string leaseId = 1; +} + +message KeepLeaseRequest { + string leaseId = 1; + int32 ttl = 2; +} + +message KeepLeaseResponse {} + +message DropLeaseRequest { + string leaseId = 1; +} + +message DropLeaseResponse {} diff --git a/sync/lock.proto b/sync/lock.proto new file mode 100644 index 0000000..1a0b7b0 --- /dev/null +++ b/sync/lock.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; +package sync; + +message LocalLockRequest { + string leaseId = 1; + string tenantId = 2; + string globalConcern = 3; + string localConcern = 4; +} + +message LocalLockResponse {} + +message LocalUnlockRequest { + string leaseId = 1; + string tenantId = 2; + string globalConcern = 3; + string localConcern = 4; +} + +message LocalUnlockResponse {} + +message GlobalLockRequest { + string leaseId = 1; + string tenantId = 2; + string globalConcern = 3; +} + +message GlobalLockResponse {} + +message GlobalUnlockRequest { + string leaseId = 1; + string tenantId = 2; + string globalConcern = 3; +} + +message GlobalUnlockResponse {} diff --git a/sync/peer_nodes.proto b/sync/peer_nodes.proto new file mode 100644 index 0000000..69da3fa --- /dev/null +++ b/sync/peer_nodes.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package sync; + +message GetPeerNodesRequest { + string app = 1; +} + +message GetPeerNodesResponse { + repeated string peerNodeIp = 1; +} diff --git a/sync/service.proto b/sync/service.proto new file mode 100644 index 0000000..5f5402e --- /dev/null +++ b/sync/service.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package sync; +import "sync/lease.proto"; +import "sync/peer_nodes.proto"; +import "sync/lock.proto"; + +service Service { + rpc CreateLease(stream CreateLeaseRequest) returns (stream CreateLeaseResponse); + rpc KeepLease(stream KeepLeaseRequest) returns (stream KeepLeaseResponse); + rpc DropLease(stream DropLeaseRequest) returns (stream DropLeaseResponse); + + rpc GetPeerNodes(GetPeerNodesRequest) returns (GetPeerNodesResponse); + + rpc LocalLock(LocalLockRequest) returns (LocalLockResponse); + rpc LocalUnlock(LocalUnlockRequest) returns (LocalUnlockResponse); + rpc GlobalLock(GlobalLockRequest) returns (GlobalLockResponse); + rpc GlobalUnlock(GlobalUnlockRequest) returns (GlobalUnlockResponse); +}