diff --git a/api/job.pb.go b/api/job.pb.go index 17341d5..7b311b4 100644 --- a/api/job.pb.go +++ b/api/job.pb.go @@ -6,7 +6,7 @@ // versions: // protoc-gen-go v1.33.0 // protoc v4.25.4 -// source: proto/job.proto +// source: proto/api/job.proto package api @@ -14,7 +14,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" + _ "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -26,127 +26,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// JobStored is the wrapped stored version of a Job which has a partition_id -// associated. -type JobStored struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // partion_id is an identifier for the job, used for distinguishing jobs with - // the same name and assigning the job to a partition. - // Doesn't need to be globally unique. - PartitionId uint32 `protobuf:"varint,1,opt,name=partition_id,json=partitionId,proto3" json:"partition_id,omitempty"` - // begin is the beginning time of the job. - // - // Types that are assignable to Begin: - // - // *JobStored_Start - // *JobStored_DueTime - Begin isJobStored_Begin `protobuf_oneof:"begin"` - // expiration is the optional time at which the job should no longer be - // scheduled and will be ignored and garbage collected thereafter. - // A job may be removed earlier if repeats are exhausted or schedule doesn't - // permit. - Expiration *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expiration,proto3,oneof" json:"expiration,omitempty"` - // job is the job spec. - Job *Job `protobuf:"bytes,5,opt,name=job,proto3" json:"job,omitempty"` -} - -func (x *JobStored) Reset() { - *x = JobStored{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_job_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JobStored) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JobStored) ProtoMessage() {} - -func (x *JobStored) ProtoReflect() protoreflect.Message { - mi := &file_proto_job_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 JobStored.ProtoReflect.Descriptor instead. -func (*JobStored) Descriptor() ([]byte, []int) { - return file_proto_job_proto_rawDescGZIP(), []int{0} -} - -func (x *JobStored) GetPartitionId() uint32 { - if x != nil { - return x.PartitionId - } - return 0 -} - -func (m *JobStored) GetBegin() isJobStored_Begin { - if m != nil { - return m.Begin - } - return nil -} - -func (x *JobStored) GetStart() *timestamppb.Timestamp { - if x, ok := x.GetBegin().(*JobStored_Start); ok { - return x.Start - } - return nil -} - -func (x *JobStored) GetDueTime() *timestamppb.Timestamp { - if x, ok := x.GetBegin().(*JobStored_DueTime); ok { - return x.DueTime - } - return nil -} - -func (x *JobStored) GetExpiration() *timestamppb.Timestamp { - if x != nil { - return x.Expiration - } - return nil -} - -func (x *JobStored) GetJob() *Job { - if x != nil { - return x.Job - } - return nil -} - -type isJobStored_Begin interface { - isJobStored_Begin() -} - -type JobStored_Start struct { - // start is the epoch time of the job whereby the clock starts on the - // schedule. The job _will not_ trigger at this time. - Start *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=start,proto3,oneof"` -} - -type JobStored_DueTime struct { - // due_time is the epoch time of the job whereby the clock starts on the - // schedule. The job _will_ trigger at this time. - DueTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=due_time,json=dueTime,proto3,oneof"` -} - -func (*JobStored_Start) isJobStored_Begin() {} - -func (*JobStored_DueTime) isJobStored_Begin() {} - // Job defines a scheduled rhythmic job stored in the database. // Job holds the desired spec of the job, not the current trigger state, held // by Counter. @@ -198,7 +77,7 @@ type Job struct { func (x *Job) Reset() { *x = Job{} if protoimpl.UnsafeEnabled { - mi := &file_proto_job_proto_msgTypes[1] + mi := &file_proto_api_job_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -211,7 +90,7 @@ func (x *Job) String() string { func (*Job) ProtoMessage() {} func (x *Job) ProtoReflect() protoreflect.Message { - mi := &file_proto_job_proto_msgTypes[1] + mi := &file_proto_api_job_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -224,7 +103,7 @@ func (x *Job) ProtoReflect() protoreflect.Message { // Deprecated: Use Job.ProtoReflect.Descriptor instead. func (*Job) Descriptor() ([]byte, []int) { - return file_proto_job_proto_rawDescGZIP(), []int{1} + return file_proto_api_job_proto_rawDescGZIP(), []int{0} } func (x *Job) GetSchedule() string { @@ -269,106 +148,71 @@ func (x *Job) GetPayload() *anypb.Any { return nil } -var File_proto_job_proto protoreflect.FileDescriptor - -var file_proto_job_proto_rawDesc = []byte{ - 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6a, 0x6f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x90, 0x02, 0x0a, 0x09, 0x4a, 0x6f, 0x62, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x64, - 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x48, 0x00, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x64, 0x75, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x07, 0x64, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x3f, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x48, 0x01, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, - 0x01, 0x12, 0x1a, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x62, 0x52, 0x03, 0x6a, 0x6f, 0x62, 0x42, 0x07, 0x0a, - 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x02, 0x0a, 0x03, 0x4a, 0x6f, 0x62, 0x12, 0x1f, 0x0a, - 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, - 0x00, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1e, - 0x0a, 0x08, 0x64, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x48, 0x01, 0x52, 0x07, 0x64, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x15, - 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x03, 0x74, - 0x74, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x03, 0x52, 0x07, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, - 0x73, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x64, - 0x75, 0x6c, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x64, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x74, 0x74, 0x6c, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x70, - 0x65, 0x61, 0x74, 0x73, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, - 0x65, 0x74, 0x63, 0x64, 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, +var File_proto_api_job_proto protoreflect.FileDescriptor + +var file_proto_api_job_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6a, 0x6f, 0x62, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, 0x03, 0x4a, 0x6f, 0x62, 0x12, 0x1f, + 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x00, 0x52, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x12, + 0x1e, 0x0a, 0x08, 0x64, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x01, 0x52, 0x07, 0x64, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, + 0x15, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x03, + 0x74, 0x74, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x03, 0x52, 0x07, 0x72, 0x65, 0x70, 0x65, 0x61, + 0x74, 0x73, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x64, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x74, 0x74, 0x6c, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, + 0x70, 0x65, 0x61, 0x74, 0x73, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, + 0x2d, 0x65, 0x74, 0x63, 0x64, 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_proto_job_proto_rawDescOnce sync.Once - file_proto_job_proto_rawDescData = file_proto_job_proto_rawDesc + file_proto_api_job_proto_rawDescOnce sync.Once + file_proto_api_job_proto_rawDescData = file_proto_api_job_proto_rawDesc ) -func file_proto_job_proto_rawDescGZIP() []byte { - file_proto_job_proto_rawDescOnce.Do(func() { - file_proto_job_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_job_proto_rawDescData) +func file_proto_api_job_proto_rawDescGZIP() []byte { + file_proto_api_job_proto_rawDescOnce.Do(func() { + file_proto_api_job_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_api_job_proto_rawDescData) }) - return file_proto_job_proto_rawDescData + return file_proto_api_job_proto_rawDescData } -var file_proto_job_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_proto_job_proto_goTypes = []interface{}{ - (*JobStored)(nil), // 0: api.JobStored - (*Job)(nil), // 1: api.Job - (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp - (*anypb.Any)(nil), // 3: google.protobuf.Any +var file_proto_api_job_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_proto_api_job_proto_goTypes = []interface{}{ + (*Job)(nil), // 0: api.Job + (*anypb.Any)(nil), // 1: google.protobuf.Any } -var file_proto_job_proto_depIdxs = []int32{ - 2, // 0: api.JobStored.start:type_name -> google.protobuf.Timestamp - 2, // 1: api.JobStored.due_time:type_name -> google.protobuf.Timestamp - 2, // 2: api.JobStored.expiration:type_name -> google.protobuf.Timestamp - 1, // 3: api.JobStored.job:type_name -> api.Job - 3, // 4: api.Job.metadata:type_name -> google.protobuf.Any - 3, // 5: api.Job.payload:type_name -> google.protobuf.Any - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name +var file_proto_api_job_proto_depIdxs = []int32{ + 1, // 0: api.Job.metadata:type_name -> google.protobuf.Any + 1, // 1: api.Job.payload:type_name -> google.protobuf.Any + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] 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_proto_job_proto_init() } -func file_proto_job_proto_init() { - if File_proto_job_proto != nil { +func init() { file_proto_api_job_proto_init() } +func file_proto_api_job_proto_init() { + if File_proto_api_job_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_proto_job_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JobStored); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_job_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proto_api_job_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Job); i { case 0: return &v.state @@ -381,27 +225,23 @@ func file_proto_job_proto_init() { } } } - file_proto_job_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*JobStored_Start)(nil), - (*JobStored_DueTime)(nil), - } - file_proto_job_proto_msgTypes[1].OneofWrappers = []interface{}{} + file_proto_api_job_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_job_proto_rawDesc, + RawDescriptor: file_proto_api_job_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_proto_job_proto_goTypes, - DependencyIndexes: file_proto_job_proto_depIdxs, - MessageInfos: file_proto_job_proto_msgTypes, + GoTypes: file_proto_api_job_proto_goTypes, + DependencyIndexes: file_proto_api_job_proto_depIdxs, + MessageInfos: file_proto_api_job_proto_msgTypes, }.Build() - File_proto_job_proto = out.File - file_proto_job_proto_rawDesc = nil - file_proto_job_proto_goTypes = nil - file_proto_job_proto_depIdxs = nil + File_proto_api_job_proto = out.File + file_proto_api_job_proto_rawDesc = nil + file_proto_api_job_proto_goTypes = nil + file_proto_api_job_proto_depIdxs = nil } diff --git a/api/list.pb.go b/api/list.pb.go index eefcc0e..294b41d 100644 --- a/api/list.pb.go +++ b/api/list.pb.go @@ -6,7 +6,7 @@ // versions: // protoc-gen-go v1.33.0 // protoc v4.25.4 -// source: proto/list.proto +// source: proto/api/list.proto package api @@ -24,6 +24,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// NamedJob is a job with a name. type NamedJob struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -38,7 +39,7 @@ type NamedJob struct { func (x *NamedJob) Reset() { *x = NamedJob{} if protoimpl.UnsafeEnabled { - mi := &file_proto_list_proto_msgTypes[0] + mi := &file_proto_api_list_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -51,7 +52,7 @@ func (x *NamedJob) String() string { func (*NamedJob) ProtoMessage() {} func (x *NamedJob) ProtoReflect() protoreflect.Message { - mi := &file_proto_list_proto_msgTypes[0] + mi := &file_proto_api_list_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -64,7 +65,7 @@ func (x *NamedJob) ProtoReflect() protoreflect.Message { // Deprecated: Use NamedJob.ProtoReflect.Descriptor instead. func (*NamedJob) Descriptor() ([]byte, []int) { - return file_proto_list_proto_rawDescGZIP(), []int{0} + return file_proto_api_list_proto_rawDescGZIP(), []int{0} } func (x *NamedJob) GetName() string { @@ -94,7 +95,7 @@ type ListResponse struct { func (x *ListResponse) Reset() { *x = ListResponse{} if protoimpl.UnsafeEnabled { - mi := &file_proto_list_proto_msgTypes[1] + mi := &file_proto_api_list_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -107,7 +108,7 @@ func (x *ListResponse) String() string { func (*ListResponse) ProtoMessage() {} func (x *ListResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_list_proto_msgTypes[1] + mi := &file_proto_api_list_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -120,7 +121,7 @@ func (x *ListResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListResponse.ProtoReflect.Descriptor instead. func (*ListResponse) Descriptor() ([]byte, []int) { - return file_proto_list_proto_rawDescGZIP(), []int{1} + return file_proto_api_list_proto_rawDescGZIP(), []int{1} } func (x *ListResponse) GetJobs() []*NamedJob { @@ -130,43 +131,43 @@ func (x *ListResponse) GetJobs() []*NamedJob { return nil } -var File_proto_list_proto protoreflect.FileDescriptor +var File_proto_api_list_proto protoreflect.FileDescriptor -var file_proto_list_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6a, - 0x6f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3a, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, - 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x62, 0x52, - 0x03, 0x6a, 0x6f, 0x62, 0x22, 0x31, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x6a, 0x6f, 0x62, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x4a, 0x6f, - 0x62, 0x52, 0x04, 0x6a, 0x6f, 0x62, 0x73, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, - 0x67, 0x6f, 0x2d, 0x65, 0x74, 0x63, 0x64, 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_proto_api_list_proto_rawDesc = []byte{ + 0x0a, 0x14, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x69, 0x73, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x13, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6a, 0x6f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x3a, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1a, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x62, 0x52, 0x03, 0x6a, 0x6f, 0x62, 0x22, 0x31, 0x0a, 0x0c, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x04, + 0x6a, 0x6f, 0x62, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x52, 0x04, 0x6a, 0x6f, 0x62, 0x73, 0x42, + 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x69, + 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x74, 0x63, 0x64, 0x2d, + 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_proto_list_proto_rawDescOnce sync.Once - file_proto_list_proto_rawDescData = file_proto_list_proto_rawDesc + file_proto_api_list_proto_rawDescOnce sync.Once + file_proto_api_list_proto_rawDescData = file_proto_api_list_proto_rawDesc ) -func file_proto_list_proto_rawDescGZIP() []byte { - file_proto_list_proto_rawDescOnce.Do(func() { - file_proto_list_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_list_proto_rawDescData) +func file_proto_api_list_proto_rawDescGZIP() []byte { + file_proto_api_list_proto_rawDescOnce.Do(func() { + file_proto_api_list_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_api_list_proto_rawDescData) }) - return file_proto_list_proto_rawDescData + return file_proto_api_list_proto_rawDescData } -var file_proto_list_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_proto_list_proto_goTypes = []interface{}{ +var file_proto_api_list_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_proto_api_list_proto_goTypes = []interface{}{ (*NamedJob)(nil), // 0: api.NamedJob (*ListResponse)(nil), // 1: api.ListResponse (*Job)(nil), // 2: api.Job } -var file_proto_list_proto_depIdxs = []int32{ +var file_proto_api_list_proto_depIdxs = []int32{ 2, // 0: api.NamedJob.job:type_name -> api.Job 0, // 1: api.ListResponse.jobs:type_name -> api.NamedJob 2, // [2:2] is the sub-list for method output_type @@ -176,14 +177,14 @@ var file_proto_list_proto_depIdxs = []int32{ 0, // [0:2] is the sub-list for field type_name } -func init() { file_proto_list_proto_init() } -func file_proto_list_proto_init() { - if File_proto_list_proto != nil { +func init() { file_proto_api_list_proto_init() } +func file_proto_api_list_proto_init() { + if File_proto_api_list_proto != nil { return } - file_proto_job_proto_init() + file_proto_api_job_proto_init() if !protoimpl.UnsafeEnabled { - file_proto_list_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proto_api_list_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*NamedJob); i { case 0: return &v.state @@ -195,7 +196,7 @@ func file_proto_list_proto_init() { return nil } } - file_proto_list_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proto_api_list_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListResponse); i { case 0: return &v.state @@ -212,18 +213,18 @@ func file_proto_list_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_list_proto_rawDesc, + RawDescriptor: file_proto_api_list_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_proto_list_proto_goTypes, - DependencyIndexes: file_proto_list_proto_depIdxs, - MessageInfos: file_proto_list_proto_msgTypes, + GoTypes: file_proto_api_list_proto_goTypes, + DependencyIndexes: file_proto_api_list_proto_depIdxs, + MessageInfos: file_proto_api_list_proto_msgTypes, }.Build() - File_proto_list_proto = out.File - file_proto_list_proto_rawDesc = nil - file_proto_list_proto_goTypes = nil - file_proto_list_proto_depIdxs = nil + File_proto_api_list_proto = out.File + file_proto_api_list_proto_rawDesc = nil + file_proto_api_list_proto_goTypes = nil + file_proto_api_list_proto_depIdxs = nil } diff --git a/api/trigger.pb.go b/api/trigger.pb.go index 8b075fc..ea806fd 100644 --- a/api/trigger.pb.go +++ b/api/trigger.pb.go @@ -6,7 +6,7 @@ // versions: // protoc-gen-go v1.33.0 // protoc v4.25.4 -// source: proto/trigger.proto +// source: proto/api/trigger.proto package api @@ -42,7 +42,7 @@ type TriggerRequest struct { func (x *TriggerRequest) Reset() { *x = TriggerRequest{} if protoimpl.UnsafeEnabled { - mi := &file_proto_trigger_proto_msgTypes[0] + mi := &file_proto_api_trigger_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -55,7 +55,7 @@ func (x *TriggerRequest) String() string { func (*TriggerRequest) ProtoMessage() {} func (x *TriggerRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_trigger_proto_msgTypes[0] + mi := &file_proto_api_trigger_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -68,7 +68,7 @@ func (x *TriggerRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TriggerRequest.ProtoReflect.Descriptor instead. func (*TriggerRequest) Descriptor() ([]byte, []int) { - return file_proto_trigger_proto_rawDescGZIP(), []int{0} + return file_proto_api_trigger_proto_rawDescGZIP(), []int{0} } func (x *TriggerRequest) GetName() string { @@ -92,44 +92,45 @@ func (x *TriggerRequest) GetPayload() *anypb.Any { return nil } -var File_proto_trigger_proto protoreflect.FileDescriptor - -var file_proto_trigger_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x86, 0x01, 0x0a, 0x0e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x08, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, - 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x27, - 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x69, 0x61, - 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x74, 0x63, 0x64, 0x2d, 0x63, - 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var File_proto_api_trigger_proto protoreflect.FileDescriptor + +var file_proto_api_trigger_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x72, 0x69, 0x67, + 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x1a, 0x19, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x86, 0x01, 0x0a, 0x0e, 0x54, 0x72, + 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x64, 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x74, + 0x63, 0x64, 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( - file_proto_trigger_proto_rawDescOnce sync.Once - file_proto_trigger_proto_rawDescData = file_proto_trigger_proto_rawDesc + file_proto_api_trigger_proto_rawDescOnce sync.Once + file_proto_api_trigger_proto_rawDescData = file_proto_api_trigger_proto_rawDesc ) -func file_proto_trigger_proto_rawDescGZIP() []byte { - file_proto_trigger_proto_rawDescOnce.Do(func() { - file_proto_trigger_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_trigger_proto_rawDescData) +func file_proto_api_trigger_proto_rawDescGZIP() []byte { + file_proto_api_trigger_proto_rawDescOnce.Do(func() { + file_proto_api_trigger_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_api_trigger_proto_rawDescData) }) - return file_proto_trigger_proto_rawDescData + return file_proto_api_trigger_proto_rawDescData } -var file_proto_trigger_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proto_trigger_proto_goTypes = []interface{}{ +var file_proto_api_trigger_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_proto_api_trigger_proto_goTypes = []interface{}{ (*TriggerRequest)(nil), // 0: api.TriggerRequest (*anypb.Any)(nil), // 1: google.protobuf.Any } -var file_proto_trigger_proto_depIdxs = []int32{ +var file_proto_api_trigger_proto_depIdxs = []int32{ 1, // 0: api.TriggerRequest.metadata:type_name -> google.protobuf.Any 1, // 1: api.TriggerRequest.payload:type_name -> google.protobuf.Any 2, // [2:2] is the sub-list for method output_type @@ -139,13 +140,13 @@ var file_proto_trigger_proto_depIdxs = []int32{ 0, // [0:2] is the sub-list for field type_name } -func init() { file_proto_trigger_proto_init() } -func file_proto_trigger_proto_init() { - if File_proto_trigger_proto != nil { +func init() { file_proto_api_trigger_proto_init() } +func file_proto_api_trigger_proto_init() { + if File_proto_api_trigger_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_proto_trigger_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proto_api_trigger_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TriggerRequest); i { case 0: return &v.state @@ -162,18 +163,18 @@ func file_proto_trigger_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_trigger_proto_rawDesc, + RawDescriptor: file_proto_api_trigger_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_proto_trigger_proto_goTypes, - DependencyIndexes: file_proto_trigger_proto_depIdxs, - MessageInfos: file_proto_trigger_proto_msgTypes, + GoTypes: file_proto_api_trigger_proto_goTypes, + DependencyIndexes: file_proto_api_trigger_proto_depIdxs, + MessageInfos: file_proto_api_trigger_proto_msgTypes, }.Build() - File_proto_trigger_proto = out.File - file_proto_trigger_proto_rawDesc = nil - file_proto_trigger_proto_goTypes = nil - file_proto_trigger_proto_depIdxs = nil + File_proto_api_trigger_proto = out.File + file_proto_api_trigger_proto_rawDesc = nil + file_proto_api_trigger_proto_goTypes = nil + file_proto_api_trigger_proto_depIdxs = nil } diff --git a/cron/cron_test.go b/cron/cron_test.go index 2f48f1f..bc01176 100644 --- a/cron/cron_test.go +++ b/cron/cron_test.go @@ -24,6 +24,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/client" "github.com/diagridio/go-etcd-cron/tests" ) @@ -335,8 +336,8 @@ func Test_schedule(t *testing.T) { client := tests.EmbeddedETCDBareClient(t) now := time.Now().UTC() - jobBytes1, err := proto.Marshal(&api.JobStored{ - Begin: &api.JobStored_DueTime{DueTime: timestamppb.New(now.Add(time.Hour))}, + jobBytes1, err := proto.Marshal(&stored.Job{ + Begin: &stored.Job_DueTime{DueTime: timestamppb.New(now.Add(time.Hour))}, PartitionId: 123, Job: &api.Job{DueTime: ptr.Of(now.Add(time.Hour).Format(time.RFC3339))}, }) @@ -344,8 +345,8 @@ func Test_schedule(t *testing.T) { _, err = client.Put(context.Background(), "abc/jobs/1", string(jobBytes1)) require.NoError(t, err) - jobBytes2, err := proto.Marshal(&api.JobStored{ - Begin: &api.JobStored_DueTime{DueTime: timestamppb.New(now)}, + jobBytes2, err := proto.Marshal(&stored.Job{ + Begin: &stored.Job_DueTime{DueTime: timestamppb.New(now)}, PartitionId: 123, Job: &api.Job{DueTime: ptr.Of(now.Format(time.RFC3339))}, }) @@ -392,8 +393,8 @@ func Test_schedule(t *testing.T) { client := tests.EmbeddedETCDBareClient(t) future := time.Now().UTC().Add(time.Hour) - jobBytes, err := proto.Marshal(&api.JobStored{ - Begin: &api.JobStored_DueTime{ + jobBytes, err := proto.Marshal(&stored.Job{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(future), }, PartitionId: 123, @@ -402,7 +403,7 @@ func Test_schedule(t *testing.T) { }, }) require.NoError(t, err) - counterBytes, err := proto.Marshal(&api.Counter{ + counterBytes, err := proto.Marshal(&stored.Counter{ LastTrigger: nil, Count: 0, JobPartitionId: 123, @@ -415,8 +416,8 @@ func Test_schedule(t *testing.T) { require.NoError(t, err) now := time.Now().UTC() - jobBytes2, err := proto.Marshal(&api.JobStored{ - Begin: &api.JobStored_DueTime{DueTime: timestamppb.New(now)}, + jobBytes2, err := proto.Marshal(&stored.Job{ + Begin: &stored.Job_DueTime{DueTime: timestamppb.New(now)}, Job: &api.Job{DueTime: ptr.Of(now.Format(time.RFC3339))}, }) require.NoError(t, err) @@ -453,8 +454,8 @@ func Test_schedule(t *testing.T) { client := tests.EmbeddedETCDBareClient(t) now := time.Now().UTC() - jobBytes, err := proto.Marshal(&api.JobStored{ - Begin: &api.JobStored_DueTime{ + jobBytes, err := proto.Marshal(&stored.Job{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(now), }, PartitionId: 123, @@ -463,7 +464,7 @@ func Test_schedule(t *testing.T) { }, }) require.NoError(t, err) - counterBytes, err := proto.Marshal(&api.Counter{ + counterBytes, err := proto.Marshal(&stored.Counter{ LastTrigger: timestamppb.New(now), Count: 1, JobPartitionId: 123, diff --git a/internal/api/api.go b/internal/api/api.go index f33460d..97ab4c0 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -15,6 +15,7 @@ import ( "google.golang.org/protobuf/proto" cronapi "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/api/validator" "github.com/diagridio/go-etcd-cron/internal/client" "github.com/diagridio/go-etcd-cron/internal/key" @@ -125,7 +126,7 @@ func (a *api) Get(ctx context.Context, name string) (*cronapi.Job, error) { return nil, nil } - var stored cronapi.JobStored + var stored stored.Job if err := proto.Unmarshal(resp.Kvs[0].Value, &stored); err != nil { return nil, fmt.Errorf("failed to unmarshal job: %w", err) } @@ -195,7 +196,7 @@ func (a *api) List(ctx context.Context, prefix string) (*cronapi.ListResponse, e jobs := make([]*cronapi.NamedJob, 0, resp.Count) for _, kv := range resp.Kvs { - var stored cronapi.JobStored + var stored stored.Job if err := proto.Unmarshal(kv.Value, &stored); err != nil { return nil, fmt.Errorf("failed to unmarshal job from prefix %q: %w", prefix, err) } diff --git a/internal/api/stored/counter.pb.go b/internal/api/stored/counter.pb.go new file mode 100644 index 0000000..be0c22d --- /dev/null +++ b/internal/api/stored/counter.pb.go @@ -0,0 +1,185 @@ +// +//Copyright (c) 2024 Diagrid Inc. +//Licensed under the MIT License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc v4.25.4 +// source: proto/stored/counter.proto + +package stored + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + 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) +) + +// Counter holds counter information for a given job. +type Counter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // job_partition_id is the parition_id of the job this counter belongs to. + // Prevents an updated job from inheriting the counter of a previous job with + // the same name. + // Doesn't need to be globally unique. + JobPartitionId uint32 `protobuf:"varint,1,opt,name=job_partition_id,json=jobPartitionId,proto3" json:"job_partition_id,omitempty"` + // count is the number of times the job has been triggered. + Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` + // last_trigger is the timestamp the job was last triggered. Used to + // determine the next time the job should be triggered. + LastTrigger *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=last_trigger,json=lastTrigger,proto3" json:"last_trigger,omitempty"` +} + +func (x *Counter) Reset() { + *x = Counter{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_stored_counter_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Counter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Counter) ProtoMessage() {} + +func (x *Counter) ProtoReflect() protoreflect.Message { + mi := &file_proto_stored_counter_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 Counter.ProtoReflect.Descriptor instead. +func (*Counter) Descriptor() ([]byte, []int) { + return file_proto_stored_counter_proto_rawDescGZIP(), []int{0} +} + +func (x *Counter) GetJobPartitionId() uint32 { + if x != nil { + return x.JobPartitionId + } + return 0 +} + +func (x *Counter) GetCount() uint32 { + if x != nil { + return x.Count + } + return 0 +} + +func (x *Counter) GetLastTrigger() *timestamppb.Timestamp { + if x != nil { + return x.LastTrigger + } + return nil +} + +var File_proto_stored_counter_proto protoreflect.FileDescriptor + +var file_proto_stored_counter_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x64, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x12, 0x28, 0x0a, 0x10, 0x6a, 0x6f, 0x62, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x6a, 0x6f, 0x62, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x3d, 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, + 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, + 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, + 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x74, 0x63, 0x64, + 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_proto_stored_counter_proto_rawDescOnce sync.Once + file_proto_stored_counter_proto_rawDescData = file_proto_stored_counter_proto_rawDesc +) + +func file_proto_stored_counter_proto_rawDescGZIP() []byte { + file_proto_stored_counter_proto_rawDescOnce.Do(func() { + file_proto_stored_counter_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_stored_counter_proto_rawDescData) + }) + return file_proto_stored_counter_proto_rawDescData +} + +var file_proto_stored_counter_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_proto_stored_counter_proto_goTypes = []interface{}{ + (*Counter)(nil), // 0: stored.Counter + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp +} +var file_proto_stored_counter_proto_depIdxs = []int32{ + 1, // 0: stored.Counter.last_trigger:type_name -> google.protobuf.Timestamp + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_proto_stored_counter_proto_init() } +func file_proto_stored_counter_proto_init() { + if File_proto_stored_counter_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_proto_stored_counter_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Counter); 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_proto_stored_counter_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_stored_counter_proto_goTypes, + DependencyIndexes: file_proto_stored_counter_proto_depIdxs, + MessageInfos: file_proto_stored_counter_proto_msgTypes, + }.Build() + File_proto_stored_counter_proto = out.File + file_proto_stored_counter_proto_rawDesc = nil + file_proto_stored_counter_proto_goTypes = nil + file_proto_stored_counter_proto_depIdxs = nil +} diff --git a/internal/api/stored/job.pb.go b/internal/api/stored/job.pb.go new file mode 100644 index 0000000..c46f88d --- /dev/null +++ b/internal/api/stored/job.pb.go @@ -0,0 +1,253 @@ +// +//Copyright (c) 2024 Diagrid Inc. +//Licensed under the MIT License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.33.0 +// protoc v4.25.4 +// source: proto/stored/job.proto + +package stored + +import ( + api "github.com/diagridio/go-etcd-cron/api" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + 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) +) + +// Job is the wrapped stored version of a Job which has a partition_id +// associated. +type Job struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // partion_id is an identifier for the job, used for distinguishing jobs with + // the same name and assigning the job to a partition. + // Doesn't need to be globally unique. + PartitionId uint32 `protobuf:"varint,1,opt,name=partition_id,json=partitionId,proto3" json:"partition_id,omitempty"` + // begin is the beginning time of the job. + // + // Types that are assignable to Begin: + // + // *Job_Start + // *Job_DueTime + Begin isJob_Begin `protobuf_oneof:"begin"` + // expiration is the optional time at which the job should no longer be + // scheduled and will be ignored and garbage collected thereafter. + // A job may be removed earlier if repeats are exhausted or schedule doesn't + // permit. + Expiration *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expiration,proto3,oneof" json:"expiration,omitempty"` + // job is the job spec. + Job *api.Job `protobuf:"bytes,5,opt,name=job,proto3" json:"job,omitempty"` +} + +func (x *Job) Reset() { + *x = Job{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_stored_job_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Job) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Job) ProtoMessage() {} + +func (x *Job) ProtoReflect() protoreflect.Message { + mi := &file_proto_stored_job_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 Job.ProtoReflect.Descriptor instead. +func (*Job) Descriptor() ([]byte, []int) { + return file_proto_stored_job_proto_rawDescGZIP(), []int{0} +} + +func (x *Job) GetPartitionId() uint32 { + if x != nil { + return x.PartitionId + } + return 0 +} + +func (m *Job) GetBegin() isJob_Begin { + if m != nil { + return m.Begin + } + return nil +} + +func (x *Job) GetStart() *timestamppb.Timestamp { + if x, ok := x.GetBegin().(*Job_Start); ok { + return x.Start + } + return nil +} + +func (x *Job) GetDueTime() *timestamppb.Timestamp { + if x, ok := x.GetBegin().(*Job_DueTime); ok { + return x.DueTime + } + return nil +} + +func (x *Job) GetExpiration() *timestamppb.Timestamp { + if x != nil { + return x.Expiration + } + return nil +} + +func (x *Job) GetJob() *api.Job { + if x != nil { + return x.Job + } + return nil +} + +type isJob_Begin interface { + isJob_Begin() +} + +type Job_Start struct { + // start is the epoch time of the job whereby the clock starts on the + // schedule. The job _will not_ trigger at this time. + Start *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=start,proto3,oneof"` +} + +type Job_DueTime struct { + // due_time is the epoch time of the job whereby the clock starts on the + // schedule. The job _will_ trigger at this time. + DueTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=due_time,json=dueTime,proto3,oneof"` +} + +func (*Job_Start) isJob_Begin() {} + +func (*Job_DueTime) isJob_Begin() {} + +var File_proto_stored_job_proto protoreflect.FileDescriptor + +var file_proto_stored_job_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x2f, 0x6a, + 0x6f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x72, 0x6f, 0x6e, 0x2e, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x64, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x6a, 0x6f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8a, 0x02, 0x0a, 0x03, + 0x4a, 0x6f, 0x62, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x48, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x64, 0x75, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x07, 0x64, 0x75, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x48, 0x01, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x88, 0x01, 0x01, 0x12, 0x1a, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x08, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x62, 0x52, 0x03, 0x6a, 0x6f, 0x62, + 0x42, 0x07, 0x0a, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x65, 0x78, + 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x69, 0x61, 0x67, 0x72, 0x69, 0x64, 0x69, 0x6f, + 0x2f, 0x67, 0x6f, 0x2d, 0x65, 0x74, 0x63, 0x64, 0x2d, 0x63, 0x72, 0x6f, 0x6e, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_stored_job_proto_rawDescOnce sync.Once + file_proto_stored_job_proto_rawDescData = file_proto_stored_job_proto_rawDesc +) + +func file_proto_stored_job_proto_rawDescGZIP() []byte { + file_proto_stored_job_proto_rawDescOnce.Do(func() { + file_proto_stored_job_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_stored_job_proto_rawDescData) + }) + return file_proto_stored_job_proto_rawDescData +} + +var file_proto_stored_job_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_proto_stored_job_proto_goTypes = []interface{}{ + (*Job)(nil), // 0: cron.stored.Job + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp + (*api.Job)(nil), // 2: api.Job +} +var file_proto_stored_job_proto_depIdxs = []int32{ + 1, // 0: cron.stored.Job.start:type_name -> google.protobuf.Timestamp + 1, // 1: cron.stored.Job.due_time:type_name -> google.protobuf.Timestamp + 1, // 2: cron.stored.Job.expiration:type_name -> google.protobuf.Timestamp + 2, // 3: cron.stored.Job.job:type_name -> api.Job + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_proto_stored_job_proto_init() } +func file_proto_stored_job_proto_init() { + if File_proto_stored_job_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_proto_stored_job_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Job); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_proto_stored_job_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*Job_Start)(nil), + (*Job_DueTime)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_stored_job_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_stored_job_proto_goTypes, + DependencyIndexes: file_proto_stored_job_proto_depIdxs, + MessageInfos: file_proto_stored_job_proto_msgTypes, + }.Build() + File_proto_stored_job_proto = out.File + file_proto_stored_job_proto_rawDesc = nil + file_proto_stored_job_proto_goTypes = nil + file_proto_stored_job_proto_depIdxs = nil +} diff --git a/internal/counter/counter.go b/internal/counter/counter.go index 89e85eb..69f2a43 100644 --- a/internal/counter/counter.go +++ b/internal/counter/counter.go @@ -13,6 +13,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/client" "github.com/diagridio/go-etcd-cron/internal/garbage" "github.com/diagridio/go-etcd-cron/internal/grave" @@ -35,7 +36,7 @@ type Options struct { Schedule scheduler.Interface // Job is the job to count. - Job *api.JobStored + Job *stored.Job // Yard is a graveyard for signalling that a job has just been deleted and // therefore it's Delete informer event should be ignored. @@ -57,8 +58,8 @@ type Counter struct { schedule scheduler.Interface yard *grave.Yard collector garbage.Interface - job *api.JobStored - count *api.Counter + job *stored.Job + count *stored.Counter next time.Time triggerRequest *api.TriggerRequest } @@ -83,7 +84,7 @@ func New(ctx context.Context, opts Options) (*Counter, bool, error) { client: opts.Client, schedule: opts.Schedule, job: opts.Job, - count: &api.Counter{JobPartitionId: opts.Job.GetPartitionId()}, + count: &stored.Counter{JobPartitionId: opts.Job.GetPartitionId()}, yard: opts.Yard, collector: opts.Collector, triggerRequest: &api.TriggerRequest{ @@ -100,7 +101,7 @@ func New(ctx context.Context, opts Options) (*Counter, bool, error) { return c, true, nil } - count := new(api.Counter) + count := new(stored.Counter) if err := proto.Unmarshal(res.Kvs[0].Value, count); err != nil { return nil, false, err } @@ -108,7 +109,7 @@ func New(ctx context.Context, opts Options) (*Counter, bool, error) { // If the job partition ID is the same, recover the counter state, else we // start again. if count.GetJobPartitionId() != opts.Job.GetPartitionId() { - count = &api.Counter{JobPartitionId: opts.Job.GetPartitionId()} + count = &stored.Counter{JobPartitionId: opts.Job.GetPartitionId()} b, err := proto.Marshal(count) if err != nil { return nil, false, err diff --git a/internal/counter/counter_test.go b/internal/counter/counter_test.go index a7c46a4..b801321 100644 --- a/internal/counter/counter_test.go +++ b/internal/counter/counter_test.go @@ -17,6 +17,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/garbage" "github.com/diagridio/go-etcd-cron/internal/grave" "github.com/diagridio/go-etcd-cron/internal/key" @@ -34,8 +35,8 @@ func Test_New(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, PartitionId: 123, @@ -43,7 +44,7 @@ func Test_New(t *testing.T) { DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: nil, Count: 0, JobPartitionId: 123, @@ -106,8 +107,8 @@ func Test_New(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, PartitionId: 123, @@ -115,7 +116,7 @@ func Test_New(t *testing.T) { DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: nil, Count: 0, JobPartitionId: 123, @@ -190,8 +191,8 @@ func Test_New(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, PartitionId: 123, @@ -199,7 +200,7 @@ func Test_New(t *testing.T) { DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: timestamppb.New(now), Count: 1, JobPartitionId: 456, @@ -261,7 +262,7 @@ func Test_New(t *testing.T) { require.Len(t, resp.Kvs, 1) assert.Equal(t, jobBytes, resp.Kvs[0].Value) - counter = &api.Counter{ + counter = &stored.Counter{ LastTrigger: nil, Count: 0, JobPartitionId: 123, @@ -281,8 +282,8 @@ func Test_New(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, PartitionId: 123, @@ -290,7 +291,7 @@ func Test_New(t *testing.T) { DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: timestamppb.New(now), Count: 1, JobPartitionId: 123, @@ -362,8 +363,8 @@ func Test_New(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, PartitionId: 123, @@ -440,8 +441,8 @@ func Test_Trigger(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Job: &api.Job{ @@ -449,7 +450,7 @@ func Test_Trigger(t *testing.T) { Schedule: ptr.Of("@every 1s"), }, } - counter := &api.Counter{LastTrigger: nil, JobPartitionId: 123} + counter := &stored.Counter{LastTrigger: nil, JobPartitionId: 123} sched, err := scheduler.NewBuilder().Scheduler(job) require.NoError(t, err) @@ -505,7 +506,7 @@ func Test_Trigger(t *testing.T) { require.Len(t, resp.Kvs, 1) assert.Equal(t, jobBytes, resp.Kvs[0].Value) - counterBytes, err = proto.Marshal(&api.Counter{ + counterBytes, err = proto.Marshal(&stored.Counter{ LastTrigger: timestamppb.New(now), JobPartitionId: 123, Count: 1, @@ -525,15 +526,15 @@ func Test_Trigger(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Job: &api.Job{ DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: nil, JobPartitionId: 123, Count: 0, @@ -608,15 +609,15 @@ func Test_tickNext(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Job: &api.Job{ DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{LastTrigger: nil, JobPartitionId: 123} + counter := &stored.Counter{LastTrigger: nil, JobPartitionId: 123} sched, err := scheduler.NewBuilder().Scheduler(job) require.NoError(t, err) @@ -684,15 +685,15 @@ func Test_tickNext(t *testing.T) { now := time.Now().UTC() - job := &api.JobStored{ - Begin: &api.JobStored_Start{ + job := &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Job: &api.Job{ DueTime: ptr.Of(now.Format(time.RFC3339)), }, } - counter := &api.Counter{ + counter := &stored.Counter{ LastTrigger: timestamppb.New(now), JobPartitionId: 123, Count: 1, @@ -763,8 +764,8 @@ func Test_updateNext(t *testing.T) { builder := scheduler.NewBuilder() - oneshot, err := builder.Scheduler(&api.JobStored{ - Begin: &api.JobStored_DueTime{ + oneshot, err := builder.Scheduler(&stored.Job{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(now), }, Job: &api.Job{ @@ -773,8 +774,8 @@ func Test_updateNext(t *testing.T) { }) require.NoError(t, err) - repeats, err := builder.Scheduler(&api.JobStored{ - Begin: &api.JobStored_Start{ + repeats, err := builder.Scheduler(&stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Job: &api.Job{ @@ -784,8 +785,8 @@ func Test_updateNext(t *testing.T) { }) require.NoError(t, err) - expires, err := builder.Scheduler(&api.JobStored{ - Begin: &api.JobStored_Start{ + expires, err := builder.Scheduler(&stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Expiration: timestamppb.New(now.Add(5 * time.Second)), @@ -804,10 +805,10 @@ func Test_updateNext(t *testing.T) { "if the number of counts is the same as repeats return false": { counter: &Counter{ schedule: repeats, - job: &api.JobStored{Job: &api.Job{ + job: &stored.Job{Job: &api.Job{ Repeats: ptr.Of(uint32(4)), }}, - count: &api.Counter{ + count: &stored.Counter{ Count: 4, }, }, @@ -816,20 +817,20 @@ func Test_updateNext(t *testing.T) { "if the number of counts is more than repeats return false (should never happen)": { counter: &Counter{ schedule: repeats, - job: &api.JobStored{Job: &api.Job{ + job: &stored.Job{Job: &api.Job{ Repeats: ptr.Of(uint32(4)), }}, - count: &api.Counter{Count: 5}, + count: &stored.Counter{Count: 5}, }, exp: false, }, "if the last trigger time if the same as the expiry, expect false": { counter: &Counter{ schedule: expires, - job: &api.JobStored{Job: &api.Job{ + job: &stored.Job{Job: &api.Job{ Repeats: ptr.Of(uint32(4)), }}, - count: &api.Counter{ + count: &stored.Counter{ Count: 2, LastTrigger: timestamppb.New(now.Add(5 * time.Second)), }, @@ -839,10 +840,10 @@ func Test_updateNext(t *testing.T) { "if the count is equal to total, return false": { counter: &Counter{ schedule: expires, - job: &api.JobStored{Job: &api.Job{ + job: &stored.Job{Job: &api.Job{ Repeats: ptr.Of(uint32(4)), }}, - count: &api.Counter{ + count: &stored.Counter{ Count: 4, LastTrigger: timestamppb.New(now), }, @@ -852,11 +853,11 @@ func Test_updateNext(t *testing.T) { "if under the number of counts, but job is past expiry time, return false": { counter: &Counter{ schedule: expires, - job: &api.JobStored{ + job: &stored.Job{ Expiration: timestamppb.New(now.Add(-5 * time.Second)), Job: new(api.Job), }, - count: &api.Counter{ + count: &stored.Counter{ Count: 0, LastTrigger: nil, }, @@ -866,8 +867,8 @@ func Test_updateNext(t *testing.T) { "if time is past the trigger time but no triggered yet for one shot, return true and set trigger time": { counter: &Counter{ schedule: oneshot, - job: &api.JobStored{Job: new(api.Job)}, - count: &api.Counter{ + job: &stored.Job{Job: new(api.Job)}, + count: &stored.Counter{ Count: 0, LastTrigger: nil, }, @@ -878,8 +879,8 @@ func Test_updateNext(t *testing.T) { "if oneshot trigger but has already been triggered, expect false": { counter: &Counter{ schedule: oneshot, - job: &api.JobStored{Job: new(api.Job)}, - count: &api.Counter{ + job: &stored.Job{Job: new(api.Job)}, + count: &stored.Counter{ Count: 1, LastTrigger: nil, }, diff --git a/internal/informer/informer.go b/internal/informer/informer.go index cfea1b9..04024f0 100644 --- a/internal/informer/informer.go +++ b/internal/informer/informer.go @@ -15,7 +15,7 @@ import ( clientv3 "go.etcd.io/etcd/client/v3" "google.golang.org/protobuf/proto" - "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/client" "github.com/diagridio/go-etcd-cron/internal/garbage" "github.com/diagridio/go-etcd-cron/internal/grave" @@ -68,7 +68,7 @@ type Event struct { Key []byte // Job is the job that was created or deleted. - Job *api.JobStored + Job *stored.Job } // New creates a new Informer. @@ -169,7 +169,7 @@ func (i *Informer) handleEvent(ev *clientv3.Event) (*Event, error) { return nil, errors.New("unexpected event type") } - var job api.JobStored + var job stored.Job if err := proto.Unmarshal(kv.Value, &job); err != nil { return nil, fmt.Errorf("failed to unmarshal job: %w", err) } diff --git a/internal/informer/informer_test.go b/internal/informer/informer_test.go index a37b5e6..53ec345 100644 --- a/internal/informer/informer_test.go +++ b/internal/informer/informer_test.go @@ -18,7 +18,7 @@ import ( clientv3 "go.etcd.io/etcd/client/v3" "google.golang.org/protobuf/proto" - "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/garbage" "github.com/diagridio/go-etcd-cron/internal/garbage/fake" "github.com/diagridio/go-etcd-cron/internal/grave" @@ -86,13 +86,13 @@ func Test_Run(t *testing.T) { collector, err := garbage.New(garbage.Options{Client: client}) require.NoError(t, err) - jobUID1, err := proto.Marshal(&api.JobStored{PartitionId: 1}) + jobUID1, err := proto.Marshal(&stored.Job{PartitionId: 1}) require.NoError(t, err) - jobUID2, err := proto.Marshal(&api.JobStored{PartitionId: 2}) + jobUID2, err := proto.Marshal(&stored.Job{PartitionId: 2}) require.NoError(t, err) - jobUID3, err := proto.Marshal(&api.JobStored{PartitionId: 3}) + jobUID3, err := proto.Marshal(&stored.Job{PartitionId: 3}) require.NoError(t, err) - jobUID4, err := proto.Marshal(&api.JobStored{PartitionId: 4}) + jobUID4, err := proto.Marshal(&stored.Job{PartitionId: 4}) require.NoError(t, err) ctx, cancel := context.WithCancel(context.Background()) @@ -101,7 +101,7 @@ func Test_Run(t *testing.T) { require.NoError(t, err) } - jobs := make([]api.JobStored, 2) + jobs := make([]stored.Job, 2) require.NoError(t, proto.Unmarshal(jobUID2, &jobs[0])) require.NoError(t, proto.Unmarshal(jobUID4, &jobs[1])) @@ -159,17 +159,17 @@ func Test_Run(t *testing.T) { collector, err := garbage.New(garbage.Options{Client: client}) require.NoError(t, err) - jobUID1, err := proto.Marshal(&api.JobStored{PartitionId: 1}) + jobUID1, err := proto.Marshal(&stored.Job{PartitionId: 1}) require.NoError(t, err) - jobUID2, err := proto.Marshal(&api.JobStored{PartitionId: 2}) + jobUID2, err := proto.Marshal(&stored.Job{PartitionId: 2}) require.NoError(t, err) - jobUID3, err := proto.Marshal(&api.JobStored{PartitionId: 3}) + jobUID3, err := proto.Marshal(&stored.Job{PartitionId: 3}) require.NoError(t, err) - jobUID4, err := proto.Marshal(&api.JobStored{PartitionId: 4}) + jobUID4, err := proto.Marshal(&stored.Job{PartitionId: 4}) require.NoError(t, err) - jobUID5, err := proto.Marshal(&api.JobStored{PartitionId: 5}) + jobUID5, err := proto.Marshal(&stored.Job{PartitionId: 5}) require.NoError(t, err) - jobUID6, err := proto.Marshal(&api.JobStored{PartitionId: 6}) + jobUID6, err := proto.Marshal(&stored.Job{PartitionId: 6}) require.NoError(t, err) ctx, cancel := context.WithCancel(context.Background()) @@ -178,7 +178,7 @@ func Test_Run(t *testing.T) { require.NoError(t, err) } - jobs := make([]api.JobStored, 3) + jobs := make([]stored.Job, 3) require.NoError(t, proto.Unmarshal(jobUID2, &jobs[0])) require.NoError(t, proto.Unmarshal(jobUID4, &jobs[1])) require.NoError(t, proto.Unmarshal(jobUID6, &jobs[2])) @@ -251,12 +251,12 @@ func Test_Run(t *testing.T) { func Test_handleEvent(t *testing.T) { t.Parallel() - jobUID1, err := proto.Marshal(&api.JobStored{PartitionId: 1}) + jobUID1, err := proto.Marshal(&stored.Job{PartitionId: 1}) require.NoError(t, err) - jobUID2, err := proto.Marshal(&api.JobStored{PartitionId: 2}) + jobUID2, err := proto.Marshal(&stored.Job{PartitionId: 2}) require.NoError(t, err) - var job2 api.JobStored + var job2 stored.Job require.NoError(t, proto.Unmarshal(jobUID2, &job2)) tests := map[string]struct { diff --git a/internal/queue/queue.go b/internal/queue/queue.go index b77a504..0798d65 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -19,6 +19,7 @@ import ( "github.com/dapr/kit/concurrency" "github.com/dapr/kit/events/queue" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/client" "github.com/diagridio/go-etcd-cron/internal/counter" "github.com/diagridio/go-etcd-cron/internal/garbage" @@ -273,7 +274,7 @@ func (q *Queue) handleTrigger(ctx context.Context, counter *counter.Counter) boo } // schedule schedules a job to it's next scheduled time. -func (q *Queue) schedule(ctx context.Context, name string, job *api.JobStored) error { +func (q *Queue) schedule(ctx context.Context, name string, job *stored.Job) error { scheduler, err := q.schedBuilder.Scheduler(job) if err != nil { return err diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index d1972c6..45c536d 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -15,6 +15,7 @@ import ( "github.com/dapr/kit/ptr" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "github.com/diagridio/go-etcd-cron/internal/garbage" "github.com/diagridio/go-etcd-cron/internal/grave" "github.com/diagridio/go-etcd-cron/internal/informer" @@ -44,8 +45,8 @@ func Test_delete_race(t *testing.T) { require.NoError(t, queue.HandleInformerEvent(context.Background(), &informer.Event{ IsPut: true, Key: []byte(jobKeys[i]), - Job: &api.JobStored{ - Begin: &api.JobStored_DueTime{DueTime: timestamppb.New(time.Now())}, + Job: &stored.Job{ + Begin: &stored.Job_DueTime{DueTime: timestamppb.New(time.Now())}, PartitionId: 1, Job: &api.Job{Schedule: ptr.Of("@every 1s")}, }, diff --git a/internal/scheduler/builder.go b/internal/scheduler/builder.go index 3a0cb6f..8d49bd1 100644 --- a/internal/scheduler/builder.go +++ b/internal/scheduler/builder.go @@ -14,6 +14,7 @@ import ( "github.com/dapr/kit/ptr" kittime "github.com/dapr/kit/time" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" "google.golang.org/protobuf/types/known/timestamppb" "k8s.io/utils/clock" ) @@ -33,7 +34,7 @@ func NewBuilder() *Builder { } // Scheduler returns the scheduler based on the given stored job. -func (b *Builder) Scheduler(job *api.JobStored) (Interface, error) { +func (b *Builder) Scheduler(job *stored.Job) (Interface, error) { if job.GetJob().Schedule == nil { return &oneshot{ dueTime: job.GetDueTime().AsTime(), @@ -53,9 +54,9 @@ func (b *Builder) Scheduler(job *api.JobStored) (Interface, error) { } switch t := job.GetBegin().(type) { - case *api.JobStored_Start: + case *stored.Job_Start: r.start = ptr.Of(t.Start.AsTime()) - case *api.JobStored_DueTime: + case *stored.Job_DueTime: r.dueTime = ptr.Of(t.DueTime.AsTime()) } @@ -63,7 +64,7 @@ func (b *Builder) Scheduler(job *api.JobStored) (Interface, error) { } // Parse parses a job into a stored job which contains a random partition ID. -func (b *Builder) Parse(job *api.Job) (*api.JobStored, error) { +func (b *Builder) Parse(job *api.Job) (*stored.Job, error) { if job.DueTime == nil && job.Schedule == nil { return nil, errors.New("job must have either a due time or a schedule") } @@ -88,7 +89,7 @@ func (b *Builder) Parse(job *api.Job) (*api.JobStored, error) { } //nolint:gosec - stored := &api.JobStored{ + storedJob := &stored.Job{ PartitionId: rand.Uint32(), Job: job, } @@ -102,11 +103,11 @@ func (b *Builder) Parse(job *api.Job) (*api.JobStored, error) { if err != nil { return nil, err } - stored.Begin = &api.JobStored_DueTime{ + storedJob.Begin = &stored.Job_DueTime{ DueTime: timestamppb.New(begin), } } else { - stored.Begin = &api.JobStored_Start{ + storedJob.Begin = &stored.Job_Start{ Start: timestamppb.New(now), } } @@ -114,7 +115,7 @@ func (b *Builder) Parse(job *api.Job) (*api.JobStored, error) { if job.Ttl != nil { start := now if job.DueTime != nil { - start = stored.GetDueTime().AsTime() + start = storedJob.GetDueTime().AsTime() } expiration, err := parsePointInTime(job.GetTtl(), start) if err != nil { @@ -125,10 +126,10 @@ func (b *Builder) Parse(job *api.Job) (*api.JobStored, error) { return nil, errors.New("ttl must be greater than due time") } - stored.Expiration = timestamppb.New(expiration) + storedJob.Expiration = timestamppb.New(expiration) } - return stored, nil + return storedJob, nil } func parsePointInTime(str string, now time.Time) (time.Time, error) { diff --git a/internal/scheduler/builder_test.go b/internal/scheduler/builder_test.go index 245bf51..2b2d7b0 100644 --- a/internal/scheduler/builder_test.go +++ b/internal/scheduler/builder_test.go @@ -17,6 +17,7 @@ import ( clocktesting "k8s.io/utils/clock/testing" "github.com/diagridio/go-etcd-cron/api" + "github.com/diagridio/go-etcd-cron/internal/api/stored" ) func Test_Scheduler(t *testing.T) { @@ -29,13 +30,13 @@ func Test_Scheduler(t *testing.T) { require.NoError(t, err) tests := map[string]struct { - job *api.JobStored + job *stored.Job expScheduler Interface expErr bool }{ "if no schedule, expect oneshot": { - job: &api.JobStored{ - Begin: &api.JobStored_DueTime{ + job: &stored.Job{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(now), }, Job: &api.Job{Schedule: nil}, @@ -44,8 +45,8 @@ func Test_Scheduler(t *testing.T) { expErr: false, }, "if schedule, expect repeats": { - job: &api.JobStored{ - Begin: &api.JobStored_Start{ + job: &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Expiration: timestamppb.New(now.Add(2 * time.Hour)), @@ -62,8 +63,8 @@ func Test_Scheduler(t *testing.T) { expErr: false, }, "if schedule, expect repeats with exp nil": { - job: &api.JobStored{ - Begin: &api.JobStored_Start{ + job: &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Expiration: nil, @@ -81,8 +82,8 @@ func Test_Scheduler(t *testing.T) { expErr: false, }, "if bad schedule string, expect error": { - job: &api.JobStored{ - Begin: &api.JobStored_Start{ + job: &stored.Job{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Expiration: timestamppb.New(now.Add(2 * time.Hour)), @@ -116,7 +117,7 @@ func Test_Parse(t *testing.T) { tests := map[string]struct { job *api.Job - expStored *api.JobStored + expStored *stored.Job expErr bool }{ "if due time and schedule nil, expect error": { @@ -165,14 +166,14 @@ func Test_Parse(t *testing.T) { Ttl: nil, Repeats: nil, }, - expStored: &api.JobStored{ + expStored: &stored.Job{ Job: &api.Job{ DueTime: ptr.Of("2024-04-24T11:42:22Z"), Schedule: nil, Ttl: nil, Repeats: nil, }, - Begin: &api.JobStored_DueTime{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(time.Date(2024, 4, 24, 11, 42, 22, 0, time.UTC)), }, Expiration: nil, @@ -186,14 +187,14 @@ func Test_Parse(t *testing.T) { Ttl: nil, Repeats: nil, }, - expStored: &api.JobStored{ + expStored: &stored.Job{ Job: &api.Job{ DueTime: ptr.Of("2024-04-24T11:42:22Z"), Schedule: ptr.Of("@every 1h"), Ttl: nil, Repeats: nil, }, - Begin: &api.JobStored_DueTime{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(time.Date(2024, 4, 24, 11, 42, 22, 0, time.UTC)), }, Expiration: nil, @@ -207,14 +208,14 @@ func Test_Parse(t *testing.T) { Ttl: ptr.Of("2h"), Repeats: nil, }, - expStored: &api.JobStored{ + expStored: &stored.Job{ Job: &api.Job{ DueTime: nil, Schedule: ptr.Of("@every 1h"), Ttl: ptr.Of("2h"), Repeats: nil, }, - Begin: &api.JobStored_Start{ + Begin: &stored.Job_Start{ Start: timestamppb.New(now), }, Expiration: timestamppb.New(now.Add(2 * time.Hour)), @@ -228,14 +229,14 @@ func Test_Parse(t *testing.T) { Ttl: ptr.Of("2h"), Repeats: ptr.Of(uint32(100)), }, - expStored: &api.JobStored{ + expStored: &stored.Job{ Job: &api.Job{ DueTime: ptr.Of("2024-04-24T11:42:22Z"), Schedule: ptr.Of("@every 1h"), Ttl: ptr.Of("2h"), Repeats: ptr.Of(uint32(100)), }, - Begin: &api.JobStored_DueTime{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(time.Date(2024, 4, 24, 11, 42, 22, 0, time.UTC)), }, Expiration: timestamppb.New(time.Date(2024, 4, 24, 13, 42, 22, 0, time.UTC)), @@ -259,14 +260,14 @@ func Test_Parse(t *testing.T) { Ttl: ptr.Of("2024-04-24T11:42:22Z"), Repeats: nil, }, - expStored: &api.JobStored{ + expStored: &stored.Job{ Job: &api.Job{ DueTime: ptr.Of("2024-04-24T11:42:22Z"), Schedule: ptr.Of("@every 1h"), Ttl: ptr.Of("2024-04-24T11:42:22Z"), Repeats: nil, }, - Begin: &api.JobStored_DueTime{ + Begin: &stored.Job_DueTime{ DueTime: timestamppb.New(time.Date(2024, 4, 24, 11, 42, 22, 0, time.UTC)), }, Expiration: timestamppb.New(time.Date(2024, 4, 24, 11, 42, 22, 0, time.UTC)), diff --git a/nix/ci.nix b/nix/ci.nix index 564942d..eb733f8 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -14,11 +14,13 @@ let echo ">> updating gomod2nix.toml" gomod2nix echo ">> updating proto files" - protoc --go_out=. \ - --go_opt=module=github.com/diagridio/go-etcd-cron \ - --go-grpc_out=. \ - --go-grpc_opt=require_unimplemented_servers=false,module=github.com/diagridio/go-etcd-cron \ - ./proto/*.proto + PROTOS=$(find ./proto/ -name "*.proto") + for proto in $PROTOS; do + protoc --go_out=. \ + --go_opt=module=github.com/diagridio/go-etcd-cron \ + --go-grpc_out=. \ + --go-grpc_opt=require_unimplemented_servers=false,module=github.com/diagridio/go-etcd-cron "$proto" + done echo ">> Updated. Please commit the changes." ''; }; diff --git a/proto/job.proto b/proto/api/job.proto similarity index 71% rename from proto/job.proto rename to proto/api/job.proto index dc31b2b..d85d413 100644 --- a/proto/job.proto +++ b/proto/api/job.proto @@ -12,35 +12,6 @@ import "google/protobuf/timestamp.proto"; option go_package = "github.com/diagridio/go-etcd-cron/api"; -// JobStored is the wrapped stored version of a Job which has a partition_id -// associated. -message JobStored { - // partion_id is an identifier for the job, used for distinguishing jobs with - // the same name and assigning the job to a partition. - // Doesn't need to be globally unique. - uint32 partition_id = 1; - - // begin is the beginning time of the job. - oneof begin { - // start is the epoch time of the job whereby the clock starts on the - // schedule. The job _will not_ trigger at this time. - google.protobuf.Timestamp start = 2; - - // due_time is the epoch time of the job whereby the clock starts on the - // schedule. The job _will_ trigger at this time. - google.protobuf.Timestamp due_time = 3; - } - - // expiration is the optional time at which the job should no longer be - // scheduled and will be ignored and garbage collected thereafter. - // A job may be removed earlier if repeats are exhausted or schedule doesn't - // permit. - optional google.protobuf.Timestamp expiration = 4; - - // job is the job spec. - Job job = 5; -} - // Job defines a scheduled rhythmic job stored in the database. // Job holds the desired spec of the job, not the current trigger state, held // by Counter. diff --git a/proto/list.proto b/proto/api/list.proto similarity index 86% rename from proto/list.proto rename to proto/api/list.proto index 14bce3d..b3652d1 100644 --- a/proto/list.proto +++ b/proto/api/list.proto @@ -7,10 +7,11 @@ syntax = "proto3"; package api; -import "proto/job.proto"; +import "proto/api/job.proto"; option go_package = "github.com/diagridio/go-etcd-cron/api"; +// NamedJob is a job with a name. message NamedJob { // name is the name of the job. string name = 1; diff --git a/proto/trigger.proto b/proto/api/trigger.proto similarity index 100% rename from proto/trigger.proto rename to proto/api/trigger.proto diff --git a/proto/counter.proto b/proto/stored/counter.proto similarity index 88% rename from proto/counter.proto rename to proto/stored/counter.proto index d3e8d20..edbc017 100644 --- a/proto/counter.proto +++ b/proto/stored/counter.proto @@ -5,11 +5,11 @@ Licensed under the MIT License. syntax = "proto3"; -package api; +package stored; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/diagridio/go-etcd-cron/api"; +option go_package = "github.com/diagridio/go-etcd-cron/internal/api/stored"; // Counter holds counter information for a given job. message Counter { diff --git a/proto/stored/job.proto b/proto/stored/job.proto new file mode 100644 index 0000000..195d002 --- /dev/null +++ b/proto/stored/job.proto @@ -0,0 +1,42 @@ +/* +Copyright (c) 2024 Diagrid Inc. +Licensed under the MIT License. +*/ + +syntax = "proto3"; + +package cron.stored; + +import "google/protobuf/timestamp.proto"; +import "proto/api/job.proto"; + +option go_package = "github.com/diagridio/go-etcd-cron/internal/api/stored"; + +// Job is the wrapped stored version of a Job which has a partition_id +// associated. +message Job { + // partion_id is an identifier for the job, used for distinguishing jobs with + // the same name and assigning the job to a partition. + // Doesn't need to be globally unique. + uint32 partition_id = 1; + + // begin is the beginning time of the job. + oneof begin { + // start is the epoch time of the job whereby the clock starts on the + // schedule. The job _will not_ trigger at this time. + google.protobuf.Timestamp start = 2; + + // due_time is the epoch time of the job whereby the clock starts on the + // schedule. The job _will_ trigger at this time. + google.protobuf.Timestamp due_time = 3; + } + + // expiration is the optional time at which the job should no longer be + // scheduled and will be ignored and garbage collected thereafter. + // A job may be removed earlier if repeats are exhausted or schedule doesn't + // permit. + optional google.protobuf.Timestamp expiration = 4; + + // job is the job spec. + api.Job job = 5; +}