mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
feat(distlock): refactor into a standalone package
This commit is contained in:
1 parent
7a7a313426
commit
613cd6e418
10 files changed
+148
-142
No files matched your search
@@ -1,5 +0,0 @@
|
|||||||
// Package distlock provides distributed, automatically renewed leases across Uncloud machines.
|
|
||||||
//
|
|
||||||
// The initial in-memory store does not preserve leases across machine daemon restarts. Cluster membership must remain
|
|
||||||
// stable while leases are active. Callers must stop protected work when the context returned by Lease.Context is done.
|
|
||||||
package distlock
|
|
||||||
@@ -44,7 +44,7 @@ run = "mise lock --platform linux-x64,macos-arm64"
|
|||||||
description = "Regenerate gRPC API code from .proto files"
|
description = "Regenerate gRPC API code from .proto files"
|
||||||
run = """
|
run = """
|
||||||
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||||
--proto_path=. --proto_path=internal/machine/api/vendor internal/machine/api/pb/*.proto
|
--proto_path=. --proto_path=internal/machine/api/vendor internal/machine/api/pb/*.proto pkg/distlock/grpc/*.proto
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[tasks.uc]
|
[tasks.uc]
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// Package distlock provides distributed, automatically renewed leases across independent nodes.
|
||||||
|
//
|
||||||
|
// A Cluster must return every node in the lock group, including temporarily unavailable nodes, because every node
|
||||||
|
// counts toward quorum. Changing the node set is unsafe if a new quorum can be disjoint from an earlier quorum while
|
||||||
|
// leases acquired from the earlier node set may still be valid. Callers must stop protected work when the context
|
||||||
|
// returned by Lease.Context is done.
|
||||||
|
package distlock
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.34.2
|
// protoc-gen-go v1.34.2
|
||||||
// protoc v5.27.3
|
// protoc v5.27.3
|
||||||
// source: internal/machine/api/pb/lease.proto
|
// source: pkg/distlock/grpc/lease.proto
|
||||||
|
|
||||||
package pb
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
@@ -36,7 +36,7 @@ type AcquireLeaseRequest struct {
|
|||||||
func (x *AcquireLeaseRequest) Reset() {
|
func (x *AcquireLeaseRequest) Reset() {
|
||||||
*x = AcquireLeaseRequest{}
|
*x = AcquireLeaseRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[0]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ func (x *AcquireLeaseRequest) String() string {
|
|||||||
func (*AcquireLeaseRequest) ProtoMessage() {}
|
func (*AcquireLeaseRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *AcquireLeaseRequest) ProtoReflect() protoreflect.Message {
|
func (x *AcquireLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[0]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -62,7 +62,7 @@ func (x *AcquireLeaseRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use AcquireLeaseRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use AcquireLeaseRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*AcquireLeaseRequest) Descriptor() ([]byte, []int) {
|
func (*AcquireLeaseRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{0}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AcquireLeaseRequest) GetResource() string {
|
func (x *AcquireLeaseRequest) GetResource() string {
|
||||||
@@ -98,7 +98,7 @@ type AcquireLeaseResponse struct {
|
|||||||
func (x *AcquireLeaseResponse) Reset() {
|
func (x *AcquireLeaseResponse) Reset() {
|
||||||
*x = AcquireLeaseResponse{}
|
*x = AcquireLeaseResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[1]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ func (x *AcquireLeaseResponse) String() string {
|
|||||||
func (*AcquireLeaseResponse) ProtoMessage() {}
|
func (*AcquireLeaseResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *AcquireLeaseResponse) ProtoReflect() protoreflect.Message {
|
func (x *AcquireLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[1]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -124,7 +124,7 @@ func (x *AcquireLeaseResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use AcquireLeaseResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use AcquireLeaseResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*AcquireLeaseResponse) Descriptor() ([]byte, []int) {
|
func (*AcquireLeaseResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{1}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AcquireLeaseResponse) GetAcquired() bool {
|
func (x *AcquireLeaseResponse) GetAcquired() bool {
|
||||||
@@ -149,7 +149,7 @@ type RenewLeaseRequest struct {
|
|||||||
func (x *RenewLeaseRequest) Reset() {
|
func (x *RenewLeaseRequest) Reset() {
|
||||||
*x = RenewLeaseRequest{}
|
*x = RenewLeaseRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[2]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ func (x *RenewLeaseRequest) String() string {
|
|||||||
func (*RenewLeaseRequest) ProtoMessage() {}
|
func (*RenewLeaseRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *RenewLeaseRequest) ProtoReflect() protoreflect.Message {
|
func (x *RenewLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[2]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -175,7 +175,7 @@ func (x *RenewLeaseRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use RenewLeaseRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use RenewLeaseRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*RenewLeaseRequest) Descriptor() ([]byte, []int) {
|
func (*RenewLeaseRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{2}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RenewLeaseRequest) GetResource() string {
|
func (x *RenewLeaseRequest) GetResource() string {
|
||||||
@@ -211,7 +211,7 @@ type RenewLeaseResponse struct {
|
|||||||
func (x *RenewLeaseResponse) Reset() {
|
func (x *RenewLeaseResponse) Reset() {
|
||||||
*x = RenewLeaseResponse{}
|
*x = RenewLeaseResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[3]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ func (x *RenewLeaseResponse) String() string {
|
|||||||
func (*RenewLeaseResponse) ProtoMessage() {}
|
func (*RenewLeaseResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *RenewLeaseResponse) ProtoReflect() protoreflect.Message {
|
func (x *RenewLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[3]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -237,7 +237,7 @@ func (x *RenewLeaseResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use RenewLeaseResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use RenewLeaseResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*RenewLeaseResponse) Descriptor() ([]byte, []int) {
|
func (*RenewLeaseResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{3}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RenewLeaseResponse) GetRenewed() bool {
|
func (x *RenewLeaseResponse) GetRenewed() bool {
|
||||||
@@ -260,7 +260,7 @@ type ReleaseLeaseRequest struct {
|
|||||||
func (x *ReleaseLeaseRequest) Reset() {
|
func (x *ReleaseLeaseRequest) Reset() {
|
||||||
*x = ReleaseLeaseRequest{}
|
*x = ReleaseLeaseRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[4]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ func (x *ReleaseLeaseRequest) String() string {
|
|||||||
func (*ReleaseLeaseRequest) ProtoMessage() {}
|
func (*ReleaseLeaseRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *ReleaseLeaseRequest) ProtoReflect() protoreflect.Message {
|
func (x *ReleaseLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[4]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -286,7 +286,7 @@ func (x *ReleaseLeaseRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use ReleaseLeaseRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ReleaseLeaseRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*ReleaseLeaseRequest) Descriptor() ([]byte, []int) {
|
func (*ReleaseLeaseRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{4}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ReleaseLeaseRequest) GetResource() string {
|
func (x *ReleaseLeaseRequest) GetResource() string {
|
||||||
@@ -315,7 +315,7 @@ type ReleaseLeaseResponse struct {
|
|||||||
func (x *ReleaseLeaseResponse) Reset() {
|
func (x *ReleaseLeaseResponse) Reset() {
|
||||||
*x = ReleaseLeaseResponse{}
|
*x = ReleaseLeaseResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[5]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[5]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ func (x *ReleaseLeaseResponse) String() string {
|
|||||||
func (*ReleaseLeaseResponse) ProtoMessage() {}
|
func (*ReleaseLeaseResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *ReleaseLeaseResponse) ProtoReflect() protoreflect.Message {
|
func (x *ReleaseLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[5]
|
mi := &file_pkg_distlock_grpc_lease_proto_msgTypes[5]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -341,7 +341,7 @@ func (x *ReleaseLeaseResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use ReleaseLeaseResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ReleaseLeaseResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*ReleaseLeaseResponse) Descriptor() ([]byte, []int) {
|
func (*ReleaseLeaseResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{5}
|
return file_pkg_distlock_grpc_lease_proto_rawDescGZIP(), []int{5}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ReleaseLeaseResponse) GetReleased() bool {
|
func (x *ReleaseLeaseResponse) GetReleased() bool {
|
||||||
@@ -351,92 +351,95 @@ func (x *ReleaseLeaseResponse) GetReleased() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_internal_machine_api_pb_lease_proto protoreflect.FileDescriptor
|
var File_pkg_distlock_grpc_lease_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_internal_machine_api_pb_lease_proto_rawDesc = []byte{
|
var file_pkg_distlock_grpc_lease_proto_rawDesc = []byte{
|
||||||
0x0a, 0x23, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
0x0a, 0x1d, 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x67,
|
||||||
0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x2f, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e,
|
0x72, 0x70, 0x63, 0x2f, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67,
|
0x0b, 0x64, 0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x1a, 0x1e, 0x67, 0x6f,
|
||||||
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61,
|
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x13, 0x41, 0x63,
|
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x13,
|
||||||
0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75,
|
||||||
|
0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18,
|
||||||
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12,
|
||||||
|
0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05,
|
||||||
|
0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2b, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01,
|
||||||
|
0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
|
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x74,
|
||||||
|
0x74, 0x6c, 0x22, 0x32, 0x0a, 0x14, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61,
|
||||||
|
0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63,
|
||||||
|
0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x63,
|
||||||
|
0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x72, 0x0a, 0x11, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x4c,
|
||||||
|
0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72,
|
||||||
|
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72,
|
||||||
|
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
|
||||||
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2b, 0x0a,
|
||||||
|
0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f,
|
||||||
|
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72,
|
||||||
|
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x2e, 0x0a, 0x12, 0x52, 0x65,
|
||||||
|
0x6e, 0x65, 0x77, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
|
0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6e, 0x65, 0x77, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
|
0x08, 0x52, 0x07, 0x72, 0x65, 0x6e, 0x65, 0x77, 0x65, 0x64, 0x22, 0x47, 0x0a, 0x13, 0x52, 0x65,
|
||||||
|
0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||||
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20,
|
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x14, 0x0a,
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x14, 0x0a,
|
||||||
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f,
|
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f,
|
||||||
0x6b, 0x65, 0x6e, 0x12, 0x2b, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
|
0x6b, 0x65, 0x6e, 0x22, 0x32, 0x0a, 0x14, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65,
|
||||||
0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72,
|
||||||
0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x74, 0x74, 0x6c,
|
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72,
|
||||||
0x22, 0x32, 0x0a, 0x14, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65,
|
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x32, 0xf1, 0x01, 0x0a, 0x05, 0x4c, 0x65, 0x61, 0x73,
|
||||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x71, 0x75,
|
0x65, 0x12, 0x4e, 0x0a, 0x07, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x12, 0x20, 0x2e, 0x64,
|
||||||
0x69, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x63, 0x71, 0x75,
|
0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69,
|
||||||
0x69, 0x72, 0x65, 0x64, 0x22, 0x72, 0x0a, 0x11, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x4c, 0x65, 0x61,
|
0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21,
|
||||||
0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73,
|
0x2e, 0x64, 0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x71,
|
||||||
0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73,
|
0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||||
0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02,
|
0x65, 0x12, 0x48, 0x0a, 0x05, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x12, 0x1e, 0x2e, 0x64, 0x69, 0x73,
|
||||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2b, 0x0a, 0x03, 0x74,
|
0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x4c, 0x65,
|
||||||
0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x64, 0x69, 0x73,
|
||||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74,
|
0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x4c, 0x65,
|
||||||
0x69, 0x6f, 0x6e, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x2e, 0x0a, 0x12, 0x52, 0x65, 0x6e, 0x65,
|
0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x07, 0x52,
|
||||||
0x77, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18,
|
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x20, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63,
|
||||||
0x0a, 0x07, 0x72, 0x65, 0x6e, 0x65, 0x77, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73,
|
||||||
0x07, 0x72, 0x65, 0x6e, 0x65, 0x77, 0x65, 0x64, 0x22, 0x47, 0x0a, 0x13, 0x52, 0x65, 0x6c, 0x65,
|
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x6c,
|
||||||
0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
0x6f, 0x63, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65,
|
||||||
0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67,
|
||||||
0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74,
|
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65,
|
||||||
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65,
|
0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x70, 0x6b, 0x67,
|
||||||
0x6e, 0x22, 0x32, 0x0a, 0x14, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73,
|
0x2f, 0x64, 0x69, 0x73, 0x74, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06,
|
||||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c,
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x65, 0x61, 0x73, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x6c,
|
|
||||||
0x65, 0x61, 0x73, 0x65, 0x64, 0x32, 0xc1, 0x01, 0x0a, 0x05, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x12,
|
|
||||||
0x3e, 0x0a, 0x07, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x12, 0x18, 0x2e, 0x61, 0x70, 0x69,
|
|
||||||
0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71,
|
|
||||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69,
|
|
||||||
0x72, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
|
||||||
0x38, 0x0a, 0x05, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x12, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52,
|
|
||||||
0x65, 0x6e, 0x65, 0x77, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
|
||||||
0x1a, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x4c, 0x65, 0x61, 0x73,
|
|
||||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x07, 0x52, 0x65, 0x6c,
|
|
||||||
0x65, 0x61, 0x73, 0x65, 0x12, 0x18, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61,
|
|
||||||
0x73, 0x65, 0x4c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19,
|
|
||||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73,
|
|
||||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74,
|
|
||||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73,
|
|
||||||
0x6b, 0x69, 0x2f, 0x75, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72,
|
|
||||||
0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f,
|
|
||||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_internal_machine_api_pb_lease_proto_rawDescOnce sync.Once
|
file_pkg_distlock_grpc_lease_proto_rawDescOnce sync.Once
|
||||||
file_internal_machine_api_pb_lease_proto_rawDescData = file_internal_machine_api_pb_lease_proto_rawDesc
|
file_pkg_distlock_grpc_lease_proto_rawDescData = file_pkg_distlock_grpc_lease_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_internal_machine_api_pb_lease_proto_rawDescGZIP() []byte {
|
func file_pkg_distlock_grpc_lease_proto_rawDescGZIP() []byte {
|
||||||
file_internal_machine_api_pb_lease_proto_rawDescOnce.Do(func() {
|
file_pkg_distlock_grpc_lease_proto_rawDescOnce.Do(func() {
|
||||||
file_internal_machine_api_pb_lease_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_machine_api_pb_lease_proto_rawDescData)
|
file_pkg_distlock_grpc_lease_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_distlock_grpc_lease_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_internal_machine_api_pb_lease_proto_rawDescData
|
return file_pkg_distlock_grpc_lease_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_internal_machine_api_pb_lease_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
var file_pkg_distlock_grpc_lease_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||||
var file_internal_machine_api_pb_lease_proto_goTypes = []any{
|
var file_pkg_distlock_grpc_lease_proto_goTypes = []any{
|
||||||
(*AcquireLeaseRequest)(nil), // 0: api.AcquireLeaseRequest
|
(*AcquireLeaseRequest)(nil), // 0: distlock.v1.AcquireLeaseRequest
|
||||||
(*AcquireLeaseResponse)(nil), // 1: api.AcquireLeaseResponse
|
(*AcquireLeaseResponse)(nil), // 1: distlock.v1.AcquireLeaseResponse
|
||||||
(*RenewLeaseRequest)(nil), // 2: api.RenewLeaseRequest
|
(*RenewLeaseRequest)(nil), // 2: distlock.v1.RenewLeaseRequest
|
||||||
(*RenewLeaseResponse)(nil), // 3: api.RenewLeaseResponse
|
(*RenewLeaseResponse)(nil), // 3: distlock.v1.RenewLeaseResponse
|
||||||
(*ReleaseLeaseRequest)(nil), // 4: api.ReleaseLeaseRequest
|
(*ReleaseLeaseRequest)(nil), // 4: distlock.v1.ReleaseLeaseRequest
|
||||||
(*ReleaseLeaseResponse)(nil), // 5: api.ReleaseLeaseResponse
|
(*ReleaseLeaseResponse)(nil), // 5: distlock.v1.ReleaseLeaseResponse
|
||||||
(*durationpb.Duration)(nil), // 6: google.protobuf.Duration
|
(*durationpb.Duration)(nil), // 6: google.protobuf.Duration
|
||||||
}
|
}
|
||||||
var file_internal_machine_api_pb_lease_proto_depIdxs = []int32{
|
var file_pkg_distlock_grpc_lease_proto_depIdxs = []int32{
|
||||||
6, // 0: api.AcquireLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
6, // 0: distlock.v1.AcquireLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
||||||
6, // 1: api.RenewLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
6, // 1: distlock.v1.RenewLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
||||||
0, // 2: api.Lease.Acquire:input_type -> api.AcquireLeaseRequest
|
0, // 2: distlock.v1.Lease.Acquire:input_type -> distlock.v1.AcquireLeaseRequest
|
||||||
2, // 3: api.Lease.Renew:input_type -> api.RenewLeaseRequest
|
2, // 3: distlock.v1.Lease.Renew:input_type -> distlock.v1.RenewLeaseRequest
|
||||||
4, // 4: api.Lease.Release:input_type -> api.ReleaseLeaseRequest
|
4, // 4: distlock.v1.Lease.Release:input_type -> distlock.v1.ReleaseLeaseRequest
|
||||||
1, // 5: api.Lease.Acquire:output_type -> api.AcquireLeaseResponse
|
1, // 5: distlock.v1.Lease.Acquire:output_type -> distlock.v1.AcquireLeaseResponse
|
||||||
3, // 6: api.Lease.Renew:output_type -> api.RenewLeaseResponse
|
3, // 6: distlock.v1.Lease.Renew:output_type -> distlock.v1.RenewLeaseResponse
|
||||||
5, // 7: api.Lease.Release:output_type -> api.ReleaseLeaseResponse
|
5, // 7: distlock.v1.Lease.Release:output_type -> distlock.v1.ReleaseLeaseResponse
|
||||||
5, // [5:8] is the sub-list for method output_type
|
5, // [5:8] is the sub-list for method output_type
|
||||||
2, // [2:5] is the sub-list for method input_type
|
2, // [2:5] is the sub-list for method input_type
|
||||||
2, // [2:2] is the sub-list for extension type_name
|
2, // [2:2] is the sub-list for extension type_name
|
||||||
@@ -444,13 +447,13 @@ var file_internal_machine_api_pb_lease_proto_depIdxs = []int32{
|
|||||||
0, // [0:2] is the sub-list for field type_name
|
0, // [0:2] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_internal_machine_api_pb_lease_proto_init() }
|
func init() { file_pkg_distlock_grpc_lease_proto_init() }
|
||||||
func file_internal_machine_api_pb_lease_proto_init() {
|
func file_pkg_distlock_grpc_lease_proto_init() {
|
||||||
if File_internal_machine_api_pb_lease_proto != nil {
|
if File_pkg_distlock_grpc_lease_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*AcquireLeaseRequest); i {
|
switch v := v.(*AcquireLeaseRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -462,7 +465,7 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*AcquireLeaseResponse); i {
|
switch v := v.(*AcquireLeaseResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -474,7 +477,7 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*RenewLeaseRequest); i {
|
switch v := v.(*RenewLeaseRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -486,7 +489,7 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*RenewLeaseResponse); i {
|
switch v := v.(*RenewLeaseResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -498,7 +501,7 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*ReleaseLeaseRequest); i {
|
switch v := v.(*ReleaseLeaseRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -510,7 +513,7 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_internal_machine_api_pb_lease_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
file_pkg_distlock_grpc_lease_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||||
switch v := v.(*ReleaseLeaseResponse); i {
|
switch v := v.(*ReleaseLeaseResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -527,18 +530,18 @@ func file_internal_machine_api_pb_lease_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_internal_machine_api_pb_lease_proto_rawDesc,
|
RawDescriptor: file_pkg_distlock_grpc_lease_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 6,
|
NumMessages: 6,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
GoTypes: file_internal_machine_api_pb_lease_proto_goTypes,
|
GoTypes: file_pkg_distlock_grpc_lease_proto_goTypes,
|
||||||
DependencyIndexes: file_internal_machine_api_pb_lease_proto_depIdxs,
|
DependencyIndexes: file_pkg_distlock_grpc_lease_proto_depIdxs,
|
||||||
MessageInfos: file_internal_machine_api_pb_lease_proto_msgTypes,
|
MessageInfos: file_pkg_distlock_grpc_lease_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_internal_machine_api_pb_lease_proto = out.File
|
File_pkg_distlock_grpc_lease_proto = out.File
|
||||||
file_internal_machine_api_pb_lease_proto_rawDesc = nil
|
file_pkg_distlock_grpc_lease_proto_rawDesc = nil
|
||||||
file_internal_machine_api_pb_lease_proto_goTypes = nil
|
file_pkg_distlock_grpc_lease_proto_goTypes = nil
|
||||||
file_internal_machine_api_pb_lease_proto_depIdxs = nil
|
file_pkg_distlock_grpc_lease_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package api;
|
package distlock.v1;
|
||||||
|
|
||||||
option go_package = "github.com/psviderski/uncloud/internal/machine/api/pb";
|
option go_package = "github.com/psviderski/uncloud/pkg/distlock/grpc";
|
||||||
|
|
||||||
import "google/protobuf/duration.proto";
|
import "google/protobuf/duration.proto";
|
||||||
|
|
||||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
// Lease provides atomic operations for time-bound ownership of resources on one node.
|
||||||
service Lease {
|
service Lease {
|
||||||
// Acquire creates a lease when the resource has no unexpired lease.
|
// Acquire creates a lease when the resource has no unexpired lease.
|
||||||
rpc Acquire(AcquireLeaseRequest) returns (AcquireLeaseResponse);
|
rpc Acquire(AcquireLeaseRequest) returns (AcquireLeaseResponse);
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
// - protoc v5.27.3
|
// - protoc v5.27.3
|
||||||
// source: internal/machine/api/pb/lease.proto
|
// source: pkg/distlock/grpc/lease.proto
|
||||||
|
|
||||||
package pb
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -19,16 +19,16 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion9
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Lease_Acquire_FullMethodName = "/api.Lease/Acquire"
|
Lease_Acquire_FullMethodName = "/distlock.v1.Lease/Acquire"
|
||||||
Lease_Renew_FullMethodName = "/api.Lease/Renew"
|
Lease_Renew_FullMethodName = "/distlock.v1.Lease/Renew"
|
||||||
Lease_Release_FullMethodName = "/api.Lease/Release"
|
Lease_Release_FullMethodName = "/distlock.v1.Lease/Release"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LeaseClient is the client API for Lease service.
|
// LeaseClient is the client API for Lease 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.
|
// 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.
|
||||||
//
|
//
|
||||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
// Lease provides atomic operations for time-bound ownership of resources on one node.
|
||||||
type LeaseClient interface {
|
type LeaseClient interface {
|
||||||
// Acquire creates a lease when the resource has no unexpired lease.
|
// Acquire creates a lease when the resource has no unexpired lease.
|
||||||
Acquire(ctx context.Context, in *AcquireLeaseRequest, opts ...grpc.CallOption) (*AcquireLeaseResponse, error)
|
Acquire(ctx context.Context, in *AcquireLeaseRequest, opts ...grpc.CallOption) (*AcquireLeaseResponse, error)
|
||||||
@@ -80,7 +80,7 @@ func (c *leaseClient) Release(ctx context.Context, in *ReleaseLeaseRequest, opts
|
|||||||
// All implementations must embed UnimplementedLeaseServer
|
// All implementations must embed UnimplementedLeaseServer
|
||||||
// for forward compatibility.
|
// for forward compatibility.
|
||||||
//
|
//
|
||||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
// Lease provides atomic operations for time-bound ownership of resources on one node.
|
||||||
type LeaseServer interface {
|
type LeaseServer interface {
|
||||||
// Acquire creates a lease when the resource has no unexpired lease.
|
// Acquire creates a lease when the resource has no unexpired lease.
|
||||||
Acquire(context.Context, *AcquireLeaseRequest) (*AcquireLeaseResponse, error)
|
Acquire(context.Context, *AcquireLeaseRequest) (*AcquireLeaseResponse, error)
|
||||||
@@ -186,7 +186,7 @@ func _Lease_Release_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Lease_ServiceDesc = grpc.ServiceDesc{
|
var Lease_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "api.Lease",
|
ServiceName: "distlock.v1.Lease",
|
||||||
HandlerType: (*LeaseServer)(nil),
|
HandlerType: (*LeaseServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
@@ -203,5 +203,5 @@ var Lease_ServiceDesc = grpc.ServiceDesc{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "internal/machine/api/pb/lease.proto",
|
Metadata: "pkg/distlock/grpc/lease.proto",
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
package distlock
|
// Package grpc provides a gRPC transport for distlock node-local lease operations.
|
||||||
|
package grpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
"github.com/psviderski/uncloud/pkg/distlock"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/types/known/durationpb"
|
"google.golang.org/protobuf/types/known/durationpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server adapts a machine-local Store to the Lease gRPC service.
|
// Server adapts a node-local distlock.Store to the Lease gRPC service.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
pb.UnimplementedLeaseServer
|
UnimplementedLeaseServer
|
||||||
store Store
|
store distlock.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a machine-local lease server.
|
// NewServer creates a node-local lease server.
|
||||||
func NewServer(store Store) *Server {
|
func NewServer(store distlock.Store) *Server {
|
||||||
return &Server{store: store}
|
return &Server{store: store}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire creates a lease when the resource has no unexpired lease.
|
// Acquire creates a lease when the resource has no unexpired lease.
|
||||||
func (s *Server) Acquire(ctx context.Context, req *pb.AcquireLeaseRequest) (*pb.AcquireLeaseResponse, error) {
|
func (s *Server) Acquire(ctx context.Context, req *AcquireLeaseRequest) (*AcquireLeaseResponse, error) {
|
||||||
ttl, err := validateLeaseRequest(req.Resource, req.Token, req.Ttl)
|
ttl, err := validateLeaseRequest(req.Resource, req.Token, req.Ttl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||||
@@ -33,11 +34,11 @@ func (s *Server) Acquire(ctx context.Context, req *pb.AcquireLeaseRequest) (*pb.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, storeStatusError(ctx, "acquire lease", err)
|
return nil, storeStatusError(ctx, "acquire lease", err)
|
||||||
}
|
}
|
||||||
return &pb.AcquireLeaseResponse{Acquired: acquired}, nil
|
return &AcquireLeaseResponse{Acquired: acquired}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renew extends an unexpired lease when its ownership token matches.
|
// Renew extends an unexpired lease when its ownership token matches.
|
||||||
func (s *Server) Renew(ctx context.Context, req *pb.RenewLeaseRequest) (*pb.RenewLeaseResponse, error) {
|
func (s *Server) Renew(ctx context.Context, req *RenewLeaseRequest) (*RenewLeaseResponse, error) {
|
||||||
ttl, err := validateLeaseRequest(req.Resource, req.Token, req.Ttl)
|
ttl, err := validateLeaseRequest(req.Resource, req.Token, req.Ttl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||||
@@ -47,11 +48,11 @@ func (s *Server) Renew(ctx context.Context, req *pb.RenewLeaseRequest) (*pb.Rene
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, storeStatusError(ctx, "renew lease", err)
|
return nil, storeStatusError(ctx, "renew lease", err)
|
||||||
}
|
}
|
||||||
return &pb.RenewLeaseResponse{Renewed: renewed}, nil
|
return &RenewLeaseResponse{Renewed: renewed}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release removes an unexpired lease when its ownership token matches.
|
// Release removes an unexpired lease when its ownership token matches.
|
||||||
func (s *Server) Release(ctx context.Context, req *pb.ReleaseLeaseRequest) (*pb.ReleaseLeaseResponse, error) {
|
func (s *Server) Release(ctx context.Context, req *ReleaseLeaseRequest) (*ReleaseLeaseResponse, error) {
|
||||||
if err := validateResourceToken(req.Resource, req.Token); err != nil {
|
if err := validateResourceToken(req.Resource, req.Token); err != nil {
|
||||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||||
}
|
}
|
||||||
@@ -60,7 +61,7 @@ func (s *Server) Release(ctx context.Context, req *pb.ReleaseLeaseRequest) (*pb.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, storeStatusError(ctx, "release lease", err)
|
return nil, storeStatusError(ctx, "release lease", err)
|
||||||
}
|
}
|
||||||
return &pb.ReleaseLeaseResponse{Released: released}, nil
|
return &ReleaseLeaseResponse{Released: released}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateLeaseRequest(resource string, token []byte, ttl *durationpb.Duration) (time.Duration, error) {
|
func validateLeaseRequest(resource string, token []byte, ttl *durationpb.Duration) (time.Duration, error) {
|
||||||
@@ -86,7 +86,7 @@ func (s *MemoryStore) Renew(
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release removes a lease when its ownership token matches.
|
// Release removes an unexpired lease when its ownership token matches.
|
||||||
func (s *MemoryStore) Release(ctx context.Context, resource string, token []byte) (bool, error) {
|
func (s *MemoryStore) Release(ctx context.Context, resource string, token []byte) (bool, error) {
|
||||||
if err := validateStoreResourceToken(ctx, resource, token); err != nil {
|
if err := validateStoreResourceToken(ctx, resource, token); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
File renamed without changes.
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Store holds machine-local lease state and provides atomic operations over it.
|
// Store holds node-local lease state and provides atomic operations over it.
|
||||||
type Store interface {
|
type Store interface {
|
||||||
// Acquire creates a lease when the resource does not have an unexpired lease.
|
// Acquire creates a lease when the resource does not have an unexpired lease.
|
||||||
Acquire(ctx context.Context, resource string, token []byte, ttl time.Duration) (bool, error)
|
Acquire(ctx context.Context, resource string, token []byte, ttl time.Duration) (bool, error)
|
||||||
Reference in new issue
Block a user