mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 20:13:33 +00:00
feat(distlock): declare Lease gRPC service API for distributed locks
This commit is contained in:
@@ -0,0 +1,544 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc v5.27.3
|
||||
// source: internal/machine/api/pb/lease.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
durationpb "google.golang.org/protobuf/types/known/durationpb"
|
||||
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 AcquireLeaseRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Resource string `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
// Token uniquely identifies the lease owner.
|
||||
Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
// TTL sets how long the lease remains valid without renewal.
|
||||
Ttl *durationpb.Duration `protobuf:"bytes,3,opt,name=ttl,proto3" json:"ttl,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseRequest) Reset() {
|
||||
*x = AcquireLeaseRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AcquireLeaseRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AcquireLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 AcquireLeaseRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AcquireLeaseRequest) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseRequest) GetResource() string {
|
||||
if x != nil {
|
||||
return x.Resource
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseRequest) GetToken() []byte {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseRequest) GetTtl() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.Ttl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type AcquireLeaseResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Acquired is true when this request successfully created the lease.
|
||||
Acquired bool `protobuf:"varint,1,opt,name=acquired,proto3" json:"acquired,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseResponse) Reset() {
|
||||
*x = AcquireLeaseResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AcquireLeaseResponse) ProtoMessage() {}
|
||||
|
||||
func (x *AcquireLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 AcquireLeaseResponse.ProtoReflect.Descriptor instead.
|
||||
func (*AcquireLeaseResponse) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *AcquireLeaseResponse) GetAcquired() bool {
|
||||
if x != nil {
|
||||
return x.Acquired
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type RenewLeaseRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Resource string `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
// Token identifies the owner of the existing lease.
|
||||
Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
// TTL sets how long the renewed lease remains valid.
|
||||
Ttl *durationpb.Duration `protobuf:"bytes,3,opt,name=ttl,proto3" json:"ttl,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RenewLeaseRequest) Reset() {
|
||||
*x = RenewLeaseRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RenewLeaseRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RenewLeaseRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RenewLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 RenewLeaseRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RenewLeaseRequest) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *RenewLeaseRequest) GetResource() string {
|
||||
if x != nil {
|
||||
return x.Resource
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RenewLeaseRequest) GetToken() []byte {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RenewLeaseRequest) GetTtl() *durationpb.Duration {
|
||||
if x != nil {
|
||||
return x.Ttl
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RenewLeaseResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Renewed is true when an unexpired lease matched the ownership token and was successfully renewed.
|
||||
Renewed bool `protobuf:"varint,1,opt,name=renewed,proto3" json:"renewed,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RenewLeaseResponse) Reset() {
|
||||
*x = RenewLeaseResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RenewLeaseResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RenewLeaseResponse) ProtoMessage() {}
|
||||
|
||||
func (x *RenewLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 RenewLeaseResponse.ProtoReflect.Descriptor instead.
|
||||
func (*RenewLeaseResponse) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *RenewLeaseResponse) GetRenewed() bool {
|
||||
if x != nil {
|
||||
return x.Renewed
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type ReleaseLeaseRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Resource string `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
// Token identifies the owner of the existing lease.
|
||||
Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseRequest) Reset() {
|
||||
*x = ReleaseLeaseRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReleaseLeaseRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ReleaseLeaseRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 ReleaseLeaseRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ReleaseLeaseRequest) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseRequest) GetResource() string {
|
||||
if x != nil {
|
||||
return x.Resource
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseRequest) GetToken() []byte {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ReleaseLeaseResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Released is true when an unexpired lease existed, matched the ownership token, and was successfully released.
|
||||
Released bool `protobuf:"varint,1,opt,name=released,proto3" json:"released,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseResponse) Reset() {
|
||||
*x = ReleaseLeaseResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_internal_machine_api_pb_lease_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReleaseLeaseResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ReleaseLeaseResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_internal_machine_api_pb_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 ReleaseLeaseResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ReleaseLeaseResponse) Descriptor() ([]byte, []int) {
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ReleaseLeaseResponse) GetReleased() bool {
|
||||
if x != nil {
|
||||
return x.Released
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_internal_machine_api_pb_lease_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_internal_machine_api_pb_lease_proto_rawDesc = []byte{
|
||||
0x0a, 0x23, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69,
|
||||
0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x2f, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x13, 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, 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, 0x22, 0x32, 0x0a, 0x14, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4c, 0x65, 0x61, 0x73,
|
||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c,
|
||||
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 (
|
||||
file_internal_machine_api_pb_lease_proto_rawDescOnce sync.Once
|
||||
file_internal_machine_api_pb_lease_proto_rawDescData = file_internal_machine_api_pb_lease_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_internal_machine_api_pb_lease_proto_rawDescGZIP() []byte {
|
||||
file_internal_machine_api_pb_lease_proto_rawDescOnce.Do(func() {
|
||||
file_internal_machine_api_pb_lease_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_machine_api_pb_lease_proto_rawDescData)
|
||||
})
|
||||
return file_internal_machine_api_pb_lease_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_internal_machine_api_pb_lease_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_internal_machine_api_pb_lease_proto_goTypes = []any{
|
||||
(*AcquireLeaseRequest)(nil), // 0: api.AcquireLeaseRequest
|
||||
(*AcquireLeaseResponse)(nil), // 1: api.AcquireLeaseResponse
|
||||
(*RenewLeaseRequest)(nil), // 2: api.RenewLeaseRequest
|
||||
(*RenewLeaseResponse)(nil), // 3: api.RenewLeaseResponse
|
||||
(*ReleaseLeaseRequest)(nil), // 4: api.ReleaseLeaseRequest
|
||||
(*ReleaseLeaseResponse)(nil), // 5: api.ReleaseLeaseResponse
|
||||
(*durationpb.Duration)(nil), // 6: google.protobuf.Duration
|
||||
}
|
||||
var file_internal_machine_api_pb_lease_proto_depIdxs = []int32{
|
||||
6, // 0: api.AcquireLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
||||
6, // 1: api.RenewLeaseRequest.ttl:type_name -> google.protobuf.Duration
|
||||
0, // 2: api.Lease.Acquire:input_type -> api.AcquireLeaseRequest
|
||||
2, // 3: api.Lease.Renew:input_type -> api.RenewLeaseRequest
|
||||
4, // 4: api.Lease.Release:input_type -> api.ReleaseLeaseRequest
|
||||
1, // 5: api.Lease.Acquire:output_type -> api.AcquireLeaseResponse
|
||||
3, // 6: api.Lease.Renew:output_type -> api.RenewLeaseResponse
|
||||
5, // 7: api.Lease.Release:output_type -> api.ReleaseLeaseResponse
|
||||
5, // [5:8] is the sub-list for method output_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 extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_internal_machine_api_pb_lease_proto_init() }
|
||||
func file_internal_machine_api_pb_lease_proto_init() {
|
||||
if File_internal_machine_api_pb_lease_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AcquireLeaseRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AcquireLeaseResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RenewLeaseRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RenewLeaseResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReleaseLeaseRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_internal_machine_api_pb_lease_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ReleaseLeaseResponse); 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_internal_machine_api_pb_lease_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_internal_machine_api_pb_lease_proto_goTypes,
|
||||
DependencyIndexes: file_internal_machine_api_pb_lease_proto_depIdxs,
|
||||
MessageInfos: file_internal_machine_api_pb_lease_proto_msgTypes,
|
||||
}.Build()
|
||||
File_internal_machine_api_pb_lease_proto = out.File
|
||||
file_internal_machine_api_pb_lease_proto_rawDesc = nil
|
||||
file_internal_machine_api_pb_lease_proto_goTypes = nil
|
||||
file_internal_machine_api_pb_lease_proto_depIdxs = nil
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package api;
|
||||
|
||||
option go_package = "github.com/psviderski/uncloud/internal/machine/api/pb";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
||||
service Lease {
|
||||
// Acquire creates a lease when the resource has no unexpired lease.
|
||||
rpc Acquire(AcquireLeaseRequest) returns (AcquireLeaseResponse);
|
||||
// Renew extends an unexpired lease when its ownership token matches.
|
||||
rpc Renew(RenewLeaseRequest) returns (RenewLeaseResponse);
|
||||
// Release removes an unexpired lease when its ownership token matches.
|
||||
rpc Release(ReleaseLeaseRequest) returns (ReleaseLeaseResponse);
|
||||
}
|
||||
|
||||
message AcquireLeaseRequest {
|
||||
string resource = 1;
|
||||
// Token uniquely identifies the lease owner.
|
||||
bytes token = 2;
|
||||
// TTL sets how long the lease remains valid without renewal.
|
||||
google.protobuf.Duration ttl = 3;
|
||||
}
|
||||
|
||||
message AcquireLeaseResponse {
|
||||
// Acquired is true when this request successfully created the lease.
|
||||
bool acquired = 1;
|
||||
}
|
||||
|
||||
message RenewLeaseRequest {
|
||||
string resource = 1;
|
||||
// Token identifies the owner of the existing lease.
|
||||
bytes token = 2;
|
||||
// TTL sets how long the renewed lease remains valid.
|
||||
google.protobuf.Duration ttl = 3;
|
||||
}
|
||||
|
||||
message RenewLeaseResponse {
|
||||
// Renewed is true when an unexpired lease matched the ownership token and was successfully renewed.
|
||||
bool renewed = 1;
|
||||
}
|
||||
|
||||
message ReleaseLeaseRequest {
|
||||
string resource = 1;
|
||||
// Token identifies the owner of the existing lease.
|
||||
bytes token = 2;
|
||||
}
|
||||
|
||||
message ReleaseLeaseResponse {
|
||||
// Released is true when an unexpired lease existed, matched the ownership token, and was successfully released.
|
||||
bool released = 1;
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.27.3
|
||||
// source: internal/machine/api/pb/lease.proto
|
||||
|
||||
package pb
|
||||
|
||||
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.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Lease_Acquire_FullMethodName = "/api.Lease/Acquire"
|
||||
Lease_Renew_FullMethodName = "/api.Lease/Renew"
|
||||
Lease_Release_FullMethodName = "/api.Lease/Release"
|
||||
)
|
||||
|
||||
// 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.
|
||||
//
|
||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
||||
type LeaseClient interface {
|
||||
// Acquire creates a lease when the resource has no unexpired lease.
|
||||
Acquire(ctx context.Context, in *AcquireLeaseRequest, opts ...grpc.CallOption) (*AcquireLeaseResponse, error)
|
||||
// Renew extends an unexpired lease when its ownership token matches.
|
||||
Renew(ctx context.Context, in *RenewLeaseRequest, opts ...grpc.CallOption) (*RenewLeaseResponse, error)
|
||||
// Release removes an unexpired lease when its ownership token matches.
|
||||
Release(ctx context.Context, in *ReleaseLeaseRequest, opts ...grpc.CallOption) (*ReleaseLeaseResponse, error)
|
||||
}
|
||||
|
||||
type leaseClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewLeaseClient(cc grpc.ClientConnInterface) LeaseClient {
|
||||
return &leaseClient{cc}
|
||||
}
|
||||
|
||||
func (c *leaseClient) Acquire(ctx context.Context, in *AcquireLeaseRequest, opts ...grpc.CallOption) (*AcquireLeaseResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AcquireLeaseResponse)
|
||||
err := c.cc.Invoke(ctx, Lease_Acquire_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *leaseClient) Renew(ctx context.Context, in *RenewLeaseRequest, opts ...grpc.CallOption) (*RenewLeaseResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RenewLeaseResponse)
|
||||
err := c.cc.Invoke(ctx, Lease_Renew_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *leaseClient) Release(ctx context.Context, in *ReleaseLeaseRequest, opts ...grpc.CallOption) (*ReleaseLeaseResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ReleaseLeaseResponse)
|
||||
err := c.cc.Invoke(ctx, Lease_Release_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LeaseServer is the server API for Lease service.
|
||||
// All implementations must embed UnimplementedLeaseServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// Lease provides atomic operations for time-bound ownership of resources on a single machine.
|
||||
type LeaseServer interface {
|
||||
// Acquire creates a lease when the resource has no unexpired lease.
|
||||
Acquire(context.Context, *AcquireLeaseRequest) (*AcquireLeaseResponse, error)
|
||||
// Renew extends an unexpired lease when its ownership token matches.
|
||||
Renew(context.Context, *RenewLeaseRequest) (*RenewLeaseResponse, error)
|
||||
// Release removes an unexpired lease when its ownership token matches.
|
||||
Release(context.Context, *ReleaseLeaseRequest) (*ReleaseLeaseResponse, error)
|
||||
mustEmbedUnimplementedLeaseServer()
|
||||
}
|
||||
|
||||
// UnimplementedLeaseServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedLeaseServer struct{}
|
||||
|
||||
func (UnimplementedLeaseServer) Acquire(context.Context, *AcquireLeaseRequest) (*AcquireLeaseResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Acquire not implemented")
|
||||
}
|
||||
func (UnimplementedLeaseServer) Renew(context.Context, *RenewLeaseRequest) (*RenewLeaseResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Renew not implemented")
|
||||
}
|
||||
func (UnimplementedLeaseServer) Release(context.Context, *ReleaseLeaseRequest) (*ReleaseLeaseResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Release not implemented")
|
||||
}
|
||||
func (UnimplementedLeaseServer) mustEmbedUnimplementedLeaseServer() {}
|
||||
func (UnimplementedLeaseServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeLeaseServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to LeaseServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeLeaseServer interface {
|
||||
mustEmbedUnimplementedLeaseServer()
|
||||
}
|
||||
|
||||
func RegisterLeaseServer(s grpc.ServiceRegistrar, srv LeaseServer) {
|
||||
// If the following call pancis, it indicates UnimplementedLeaseServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Lease_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Lease_Acquire_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AcquireLeaseRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LeaseServer).Acquire(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Lease_Acquire_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LeaseServer).Acquire(ctx, req.(*AcquireLeaseRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Lease_Renew_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RenewLeaseRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LeaseServer).Renew(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Lease_Renew_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LeaseServer).Renew(ctx, req.(*RenewLeaseRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Lease_Release_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ReleaseLeaseRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LeaseServer).Release(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Lease_Release_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LeaseServer).Release(ctx, req.(*ReleaseLeaseRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Lease_ServiceDesc is the grpc.ServiceDesc for Lease service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Lease_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "api.Lease",
|
||||
HandlerType: (*LeaseServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Acquire",
|
||||
Handler: _Lease_Acquire_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Renew",
|
||||
Handler: _Lease_Renew_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Release",
|
||||
Handler: _Lease_Release_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "internal/machine/api/pb/lease.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user