diff --git a/pkg/blockbuilder/scheduler/scheduler_test.go b/pkg/blockbuilder/scheduler/scheduler_test.go index bd9e00450dfa7..35e53ee255993 100644 --- a/pkg/blockbuilder/scheduler/scheduler_test.go +++ b/pkg/blockbuilder/scheduler/scheduler_test.go @@ -15,15 +15,15 @@ import ( type testEnv struct { queue *JobQueue scheduler *BlockScheduler - transport *builder.MemoryTransport + transport *types.MemoryTransport builder *builder.Worker } func newTestEnv(builderID string) *testEnv { queue := NewJobQueue() scheduler := NewScheduler(Config{}, queue, nil, log.NewNopLogger(), prometheus.NewRegistry()) - transport := builder.NewMemoryTransport(scheduler) - builder := builder.NewWorker(builderID, builder.NewMemoryTransport(scheduler)) + transport := types.NewMemoryTransport(scheduler) + builder := builder.NewWorker(builderID, transport) return &testEnv{ queue: queue, @@ -89,7 +89,7 @@ func TestMultipleBuilders(t *testing.T) { // Create first environment env1 := newTestEnv("test-builder-1") // Create second builder using same scheduler - builder2 := builder.NewWorker("test-builder-2", builder.NewMemoryTransport(env1.scheduler)) + builder2 := builder.NewWorker("test-builder-2", env1.transport) ctx := context.Background() diff --git a/pkg/blockbuilder/types/grpc_transport.go b/pkg/blockbuilder/types/grpc_transport.go new file mode 100644 index 0000000000000..675eb92413ac7 --- /dev/null +++ b/pkg/blockbuilder/types/grpc_transport.go @@ -0,0 +1,147 @@ +package types + +import ( + "context" + "flag" + "io" + + "github.com/grafana/dskit/grpcclient" + "github.com/grafana/dskit/instrument" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" + "google.golang.org/grpc" + "google.golang.org/grpc/health/grpc_health_v1" + + "github.com/grafana/loki/v3/pkg/blockbuilder/types/proto" + "github.com/grafana/loki/v3/pkg/util/constants" +) + +var _ Transport = &GRPCTransport{} + +type GRPCTransportConfig struct { + Address string `yaml:"address,omitempty"` + + // GRPCClientConfig configures the gRPC connection between the Bloom Gateway client and the server. + GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"` +} + +func (cfg *GRPCTransportConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { + f.StringVar(&cfg.Address, prefix+"address", "", "address in DNS Service Discovery format: https://grafana.com/docs/mimir/latest/configure/about-dns-service-discovery/#supported-discovery-modes") +} + +type grpcTransportMetrics struct { + requestLatency *prometheus.HistogramVec +} + +func newGRPCTransportMetrics(registerer prometheus.Registerer) *grpcTransportMetrics { + return &grpcTransportMetrics{ + requestLatency: promauto.With(registerer).NewHistogramVec(prometheus.HistogramOpts{ + Namespace: constants.Loki, + Subsystem: "block_builder_grpc", + Name: "request_duration_seconds", + Help: "Time (in seconds) spent serving requests when using the block builder grpc transport", + Buckets: instrument.DefBuckets, + }, []string{"operation", "status_code"}), + } +} + +// GRPCTransport implements the Transport interface using gRPC +type GRPCTransport struct { + grpc_health_v1.HealthClient + io.Closer + proto.BlockBuilderServiceClient +} + +// NewGRPCTransportFromAddress creates a new gRPC transport instance from an address and dial options +func NewGRPCTransportFromAddress( + metrics *grpcTransportMetrics, + cfg GRPCTransportConfig, +) (*GRPCTransport, error) { + + dialOpts, err := cfg.GRPCClientConfig.DialOption(grpcclient.Instrument(metrics.requestLatency)) + if err != nil { + return nil, err + } + + // nolint:staticcheck // grpc.Dial() has been deprecated; we'll address it before upgrading to gRPC 2. + conn, err := grpc.Dial(cfg.Address, dialOpts...) + if err != nil { + return nil, errors.Wrap(err, "new grpc pool dial") + } + + return &GRPCTransport{ + Closer: conn, + HealthClient: grpc_health_v1.NewHealthClient(conn), + BlockBuilderServiceClient: proto.NewBlockBuilderServiceClient(conn), + }, nil +} + +// SendGetJobRequest implements Transport +func (t *GRPCTransport) SendGetJobRequest(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error) { + protoReq := &proto.GetJobRequest{ + BuilderId: req.BuilderID, + } + + resp, err := t.GetJob(ctx, protoReq) + if err != nil { + return nil, err + } + + return &GetJobResponse{ + Job: protoToJob(resp.GetJob()), + OK: resp.GetOk(), + }, nil +} + +// SendCompleteJob implements Transport +func (t *GRPCTransport) SendCompleteJob(ctx context.Context, req *CompleteJobRequest) error { + protoReq := &proto.CompleteJobRequest{ + BuilderId: req.BuilderID, + Job: jobToProto(req.Job), + } + + _, err := t.CompleteJob(ctx, protoReq) + return err +} + +// SendSyncJob implements Transport +func (t *GRPCTransport) SendSyncJob(ctx context.Context, req *SyncJobRequest) error { + protoReq := &proto.SyncJobRequest{ + BuilderId: req.BuilderID, + Job: jobToProto(req.Job), + } + + _, err := t.SyncJob(ctx, protoReq) + return err +} + +// protoToJob converts a proto Job to a types.Job +func protoToJob(p *proto.Job) *Job { + if p == nil { + return nil + } + return &Job{ + ID: p.GetId(), + Partition: int(p.GetPartition()), + Offsets: Offsets{ + Min: p.GetOffsets().GetMin(), + Max: p.GetOffsets().GetMax(), + }, + } +} + +// jobToProto converts a types.Job to a proto Job +func jobToProto(j *Job) *proto.Job { + if j == nil { + return nil + } + return &proto.Job{ + Id: j.ID, + Partition: int32(j.Partition), + Offsets: &proto.Offsets{ + Min: j.Offsets.Min, + Max: j.Offsets.Max, + }, + } +} diff --git a/pkg/blockbuilder/types/interfaces.go b/pkg/blockbuilder/types/interfaces.go index 74267f912fd7e..dd719757ba6a1 100644 --- a/pkg/blockbuilder/types/interfaces.go +++ b/pkg/blockbuilder/types/interfaces.go @@ -24,6 +24,15 @@ type Scheduler interface { // Transport defines the interface for communication between block builders and scheduler type Transport interface { + BuilderTransport + SchedulerTransport +} + +// SchedulerTransport is for calls originating from the scheduler +type SchedulerTransport interface{} + +// BuilderTransport is for calls originating from the builder +type BuilderTransport interface { // SendGetJobRequest sends a request to get a new job SendGetJobRequest(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error) // SendCompleteJob sends a job completion notification diff --git a/pkg/blockbuilder/types/job.go b/pkg/blockbuilder/types/job.go index d6ed42b598906..2c06fec4d48cd 100644 --- a/pkg/blockbuilder/types/job.go +++ b/pkg/blockbuilder/types/job.go @@ -4,8 +4,7 @@ import "fmt" // Job represents a block building task. type Job struct { - ID string - Status JobStatus + ID string // Partition and offset information Partition int Offsets Offsets @@ -30,7 +29,6 @@ type Offsets struct { func NewJob(partition int, offsets Offsets) *Job { return &Job{ ID: GenerateJobID(partition, offsets), - Status: JobStatusPending, Partition: partition, Offsets: offsets, } diff --git a/pkg/blockbuilder/types/proto/blockbuilder.pb.go b/pkg/blockbuilder/types/proto/blockbuilder.pb.go new file mode 100644 index 0000000000000..c5c4b05d38604 --- /dev/null +++ b/pkg/blockbuilder/types/proto/blockbuilder.pb.go @@ -0,0 +1,2317 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/blockbuilder/types/proto/blockbuilder.proto + +package proto + +import ( + context "context" + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GetJobRequest represents a request for a new job +type GetJobRequest struct { + BuilderId string `protobuf:"bytes,1,opt,name=builder_id,json=builderId,proto3" json:"builder_id,omitempty"` +} + +func (m *GetJobRequest) Reset() { *m = GetJobRequest{} } +func (*GetJobRequest) ProtoMessage() {} +func (*GetJobRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{0} +} +func (m *GetJobRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetJobRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetJobRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetJobRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetJobRequest.Merge(m, src) +} +func (m *GetJobRequest) XXX_Size() int { + return m.Size() +} +func (m *GetJobRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetJobRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetJobRequest proto.InternalMessageInfo + +func (m *GetJobRequest) GetBuilderId() string { + if m != nil { + return m.BuilderId + } + return "" +} + +// GetJobResponse contains the response for a job request +type GetJobResponse struct { + Job *Job `protobuf:"bytes,1,opt,name=job,proto3" json:"job,omitempty"` + Ok bool `protobuf:"varint,2,opt,name=ok,proto3" json:"ok,omitempty"` +} + +func (m *GetJobResponse) Reset() { *m = GetJobResponse{} } +func (*GetJobResponse) ProtoMessage() {} +func (*GetJobResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{1} +} +func (m *GetJobResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetJobResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetJobResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetJobResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetJobResponse.Merge(m, src) +} +func (m *GetJobResponse) XXX_Size() int { + return m.Size() +} +func (m *GetJobResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetJobResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetJobResponse proto.InternalMessageInfo + +func (m *GetJobResponse) GetJob() *Job { + if m != nil { + return m.Job + } + return nil +} + +func (m *GetJobResponse) GetOk() bool { + if m != nil { + return m.Ok + } + return false +} + +// CompleteJobRequest represents a job completion notification +type CompleteJobRequest struct { + BuilderId string `protobuf:"bytes,1,opt,name=builder_id,json=builderId,proto3" json:"builder_id,omitempty"` + Job *Job `protobuf:"bytes,2,opt,name=job,proto3" json:"job,omitempty"` +} + +func (m *CompleteJobRequest) Reset() { *m = CompleteJobRequest{} } +func (*CompleteJobRequest) ProtoMessage() {} +func (*CompleteJobRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{2} +} +func (m *CompleteJobRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompleteJobRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompleteJobRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompleteJobRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompleteJobRequest.Merge(m, src) +} +func (m *CompleteJobRequest) XXX_Size() int { + return m.Size() +} +func (m *CompleteJobRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CompleteJobRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CompleteJobRequest proto.InternalMessageInfo + +func (m *CompleteJobRequest) GetBuilderId() string { + if m != nil { + return m.BuilderId + } + return "" +} + +func (m *CompleteJobRequest) GetJob() *Job { + if m != nil { + return m.Job + } + return nil +} + +// CompleteJobResponse is an empty response for job completion +type CompleteJobResponse struct { +} + +func (m *CompleteJobResponse) Reset() { *m = CompleteJobResponse{} } +func (*CompleteJobResponse) ProtoMessage() {} +func (*CompleteJobResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{3} +} +func (m *CompleteJobResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CompleteJobResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CompleteJobResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CompleteJobResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CompleteJobResponse.Merge(m, src) +} +func (m *CompleteJobResponse) XXX_Size() int { + return m.Size() +} +func (m *CompleteJobResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CompleteJobResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CompleteJobResponse proto.InternalMessageInfo + +// SyncJobRequest represents a job sync request +type SyncJobRequest struct { + BuilderId string `protobuf:"bytes,1,opt,name=builder_id,json=builderId,proto3" json:"builder_id,omitempty"` + Job *Job `protobuf:"bytes,2,opt,name=job,proto3" json:"job,omitempty"` +} + +func (m *SyncJobRequest) Reset() { *m = SyncJobRequest{} } +func (*SyncJobRequest) ProtoMessage() {} +func (*SyncJobRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{4} +} +func (m *SyncJobRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SyncJobRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SyncJobRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SyncJobRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SyncJobRequest.Merge(m, src) +} +func (m *SyncJobRequest) XXX_Size() int { + return m.Size() +} +func (m *SyncJobRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SyncJobRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SyncJobRequest proto.InternalMessageInfo + +func (m *SyncJobRequest) GetBuilderId() string { + if m != nil { + return m.BuilderId + } + return "" +} + +func (m *SyncJobRequest) GetJob() *Job { + if m != nil { + return m.Job + } + return nil +} + +// SyncJobResponse is an empty response for job sync +type SyncJobResponse struct { +} + +func (m *SyncJobResponse) Reset() { *m = SyncJobResponse{} } +func (*SyncJobResponse) ProtoMessage() {} +func (*SyncJobResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{5} +} +func (m *SyncJobResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SyncJobResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SyncJobResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SyncJobResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SyncJobResponse.Merge(m, src) +} +func (m *SyncJobResponse) XXX_Size() int { + return m.Size() +} +func (m *SyncJobResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SyncJobResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SyncJobResponse proto.InternalMessageInfo + +// Offsets represents the start and end offsets for a job +type Offsets struct { + Min int64 `protobuf:"varint,1,opt,name=min,proto3" json:"min,omitempty"` + Max int64 `protobuf:"varint,2,opt,name=max,proto3" json:"max,omitempty"` +} + +func (m *Offsets) Reset() { *m = Offsets{} } +func (*Offsets) ProtoMessage() {} +func (*Offsets) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{6} +} +func (m *Offsets) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Offsets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Offsets.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Offsets) XXX_Merge(src proto.Message) { + xxx_messageInfo_Offsets.Merge(m, src) +} +func (m *Offsets) XXX_Size() int { + return m.Size() +} +func (m *Offsets) XXX_DiscardUnknown() { + xxx_messageInfo_Offsets.DiscardUnknown(m) +} + +var xxx_messageInfo_Offsets proto.InternalMessageInfo + +func (m *Offsets) GetMin() int64 { + if m != nil { + return m.Min + } + return 0 +} + +func (m *Offsets) GetMax() int64 { + if m != nil { + return m.Max + } + return 0 +} + +// Job represents a block building job +type Job struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Partition int32 `protobuf:"varint,2,opt,name=partition,proto3" json:"partition,omitempty"` + Offsets *Offsets `protobuf:"bytes,3,opt,name=offsets,proto3" json:"offsets,omitempty"` +} + +func (m *Job) Reset() { *m = Job{} } +func (*Job) ProtoMessage() {} +func (*Job) Descriptor() ([]byte, []int) { + return fileDescriptor_04968622516f7b79, []int{7} +} +func (m *Job) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Job) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Job.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Job) XXX_Merge(src proto.Message) { + xxx_messageInfo_Job.Merge(m, src) +} +func (m *Job) XXX_Size() int { + return m.Size() +} +func (m *Job) XXX_DiscardUnknown() { + xxx_messageInfo_Job.DiscardUnknown(m) +} + +var xxx_messageInfo_Job proto.InternalMessageInfo + +func (m *Job) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Job) GetPartition() int32 { + if m != nil { + return m.Partition + } + return 0 +} + +func (m *Job) GetOffsets() *Offsets { + if m != nil { + return m.Offsets + } + return nil +} + +func init() { + proto.RegisterType((*GetJobRequest)(nil), "blockbuilder.types.GetJobRequest") + proto.RegisterType((*GetJobResponse)(nil), "blockbuilder.types.GetJobResponse") + proto.RegisterType((*CompleteJobRequest)(nil), "blockbuilder.types.CompleteJobRequest") + proto.RegisterType((*CompleteJobResponse)(nil), "blockbuilder.types.CompleteJobResponse") + proto.RegisterType((*SyncJobRequest)(nil), "blockbuilder.types.SyncJobRequest") + proto.RegisterType((*SyncJobResponse)(nil), "blockbuilder.types.SyncJobResponse") + proto.RegisterType((*Offsets)(nil), "blockbuilder.types.Offsets") + proto.RegisterType((*Job)(nil), "blockbuilder.types.Job") +} + +func init() { + proto.RegisterFile("pkg/blockbuilder/types/proto/blockbuilder.proto", fileDescriptor_04968622516f7b79) +} + +var fileDescriptor_04968622516f7b79 = []byte{ + // 438 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xcf, 0xae, 0xd2, 0x40, + 0x18, 0xc5, 0x3b, 0x6d, 0xbc, 0xc8, 0x77, 0x23, 0xea, 0xdc, 0x18, 0x09, 0xea, 0xe4, 0x5a, 0x13, + 0xbd, 0x2e, 0x6c, 0x13, 0xd4, 0x17, 0xc0, 0x85, 0x11, 0x17, 0xc6, 0xe2, 0x8a, 0x85, 0xda, 0x3f, + 0x03, 0x0e, 0x2d, 0x9d, 0xda, 0x0e, 0x06, 0x76, 0x3e, 0x82, 0x8f, 0xe0, 0xd2, 0x47, 0x71, 0xc9, + 0x92, 0xa5, 0x94, 0x8d, 0x4b, 0x1e, 0xc1, 0x74, 0xda, 0xa2, 0x0d, 0x0d, 0xb8, 0xb9, 0xab, 0x36, + 0xa7, 0xbf, 0x9e, 0x73, 0xf2, 0x7d, 0x33, 0x60, 0x46, 0xfe, 0xd8, 0x74, 0x02, 0xee, 0xfa, 0xce, + 0x8c, 0x05, 0x1e, 0x8d, 0x4d, 0xb1, 0x88, 0x68, 0x62, 0x46, 0x31, 0x17, 0xbc, 0xf2, 0xc1, 0x90, + 0x12, 0xc6, 0x15, 0x4d, 0xc2, 0xba, 0x01, 0xd7, 0x5e, 0x52, 0xd1, 0xe7, 0x8e, 0x45, 0x3f, 0xcf, + 0x68, 0x22, 0xf0, 0x3d, 0x80, 0x82, 0xf8, 0xc0, 0xbc, 0x36, 0x3a, 0x47, 0x17, 0x4d, 0xab, 0x59, + 0x28, 0xaf, 0x3c, 0xfd, 0x35, 0xb4, 0x4a, 0x3e, 0x89, 0x78, 0x98, 0x50, 0xfc, 0x18, 0xb4, 0x09, + 0x77, 0x24, 0x79, 0xda, 0xbd, 0x6d, 0xec, 0x67, 0x18, 0x19, 0x9d, 0x31, 0xb8, 0x05, 0x2a, 0xf7, + 0xdb, 0xea, 0x39, 0xba, 0xb8, 0x6a, 0xa9, 0xdc, 0xd7, 0xdf, 0x03, 0x7e, 0xc1, 0xa7, 0x51, 0x40, + 0x05, 0xfd, 0xef, 0x06, 0x65, 0x9e, 0x7a, 0x3c, 0x4f, 0xbf, 0x05, 0x67, 0x15, 0xff, 0xbc, 0xb1, + 0x3e, 0x84, 0xd6, 0x60, 0x11, 0xba, 0x97, 0x12, 0x79, 0x13, 0xae, 0xef, 0xbc, 0x8b, 0xb8, 0x27, + 0xd0, 0x78, 0x33, 0x1a, 0x25, 0x54, 0x24, 0xf8, 0x06, 0x68, 0x53, 0x16, 0xca, 0x00, 0xcd, 0xca, + 0x5e, 0xa5, 0x62, 0xcf, 0xa5, 0x75, 0xa6, 0xd8, 0x73, 0x7d, 0x02, 0x5a, 0x3f, 0x9f, 0xd5, 0xae, + 0x8a, 0xca, 0x3c, 0x7c, 0x17, 0x9a, 0x91, 0x1d, 0x0b, 0x26, 0x18, 0x0f, 0x25, 0x7e, 0xc5, 0xfa, + 0x2b, 0xe0, 0xe7, 0xd0, 0xe0, 0x79, 0x46, 0x5b, 0x93, 0x2d, 0xef, 0xd4, 0xb5, 0x2c, 0x6a, 0x58, + 0x25, 0xdb, 0xfd, 0xae, 0xc2, 0x59, 0x2f, 0xe3, 0x7a, 0x39, 0x37, 0xa0, 0xf1, 0x17, 0xe6, 0x52, + 0xfc, 0x16, 0x4e, 0xf2, 0x2d, 0xe3, 0xfb, 0x75, 0x3e, 0x95, 0x13, 0xd3, 0xd1, 0x0f, 0x21, 0xc5, + 0x0c, 0x14, 0xfc, 0x11, 0x4e, 0xff, 0xd9, 0x05, 0x7e, 0x58, 0xf7, 0xd3, 0xfe, 0x61, 0xe8, 0x3c, + 0x3a, 0xca, 0xed, 0x12, 0xde, 0x41, 0xa3, 0x18, 0x3d, 0xae, 0xad, 0x54, 0xdd, 0x79, 0xe7, 0xc1, + 0x41, 0xa6, 0x74, 0xed, 0x4d, 0x96, 0x6b, 0xa2, 0xac, 0xd6, 0x44, 0xd9, 0xae, 0x09, 0xfa, 0x9a, + 0x12, 0xf4, 0x23, 0x25, 0xe8, 0x67, 0x4a, 0xd0, 0x32, 0x25, 0xe8, 0x57, 0x4a, 0xd0, 0xef, 0x94, + 0x28, 0xdb, 0x94, 0xa0, 0x6f, 0x1b, 0xa2, 0x2c, 0x37, 0x44, 0x59, 0x6d, 0x88, 0x32, 0x7c, 0x36, + 0x66, 0xe2, 0xd3, 0xcc, 0x31, 0x5c, 0x3e, 0x35, 0xc7, 0xb1, 0x3d, 0xb2, 0x43, 0xdb, 0x0c, 0xb8, + 0xcf, 0x0e, 0xde, 0x59, 0xe7, 0x44, 0x3e, 0x9e, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x42, + 0xf6, 0xf1, 0xda, 0x03, 0x00, 0x00, +} + +func (this *GetJobRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GetJobRequest) + if !ok { + that2, ok := that.(GetJobRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.BuilderId != that1.BuilderId { + return false + } + return true +} +func (this *GetJobResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GetJobResponse) + if !ok { + that2, ok := that.(GetJobResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Job.Equal(that1.Job) { + return false + } + if this.Ok != that1.Ok { + return false + } + return true +} +func (this *CompleteJobRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CompleteJobRequest) + if !ok { + that2, ok := that.(CompleteJobRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.BuilderId != that1.BuilderId { + return false + } + if !this.Job.Equal(that1.Job) { + return false + } + return true +} +func (this *CompleteJobResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CompleteJobResponse) + if !ok { + that2, ok := that.(CompleteJobResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *SyncJobRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SyncJobRequest) + if !ok { + that2, ok := that.(SyncJobRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.BuilderId != that1.BuilderId { + return false + } + if !this.Job.Equal(that1.Job) { + return false + } + return true +} +func (this *SyncJobResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SyncJobResponse) + if !ok { + that2, ok := that.(SyncJobResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + return true +} +func (this *Offsets) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Offsets) + if !ok { + that2, ok := that.(Offsets) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Min != that1.Min { + return false + } + if this.Max != that1.Max { + return false + } + return true +} +func (this *Job) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Job) + if !ok { + that2, ok := that.(Job) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Id != that1.Id { + return false + } + if this.Partition != that1.Partition { + return false + } + if !this.Offsets.Equal(that1.Offsets) { + return false + } + return true +} +func (this *GetJobRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&proto.GetJobRequest{") + s = append(s, "BuilderId: "+fmt.Sprintf("%#v", this.BuilderId)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *GetJobResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&proto.GetJobResponse{") + if this.Job != nil { + s = append(s, "Job: "+fmt.Sprintf("%#v", this.Job)+",\n") + } + s = append(s, "Ok: "+fmt.Sprintf("%#v", this.Ok)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *CompleteJobRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&proto.CompleteJobRequest{") + s = append(s, "BuilderId: "+fmt.Sprintf("%#v", this.BuilderId)+",\n") + if this.Job != nil { + s = append(s, "Job: "+fmt.Sprintf("%#v", this.Job)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *CompleteJobResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 4) + s = append(s, "&proto.CompleteJobResponse{") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *SyncJobRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&proto.SyncJobRequest{") + s = append(s, "BuilderId: "+fmt.Sprintf("%#v", this.BuilderId)+",\n") + if this.Job != nil { + s = append(s, "Job: "+fmt.Sprintf("%#v", this.Job)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *SyncJobResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 4) + s = append(s, "&proto.SyncJobResponse{") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Offsets) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&proto.Offsets{") + s = append(s, "Min: "+fmt.Sprintf("%#v", this.Min)+",\n") + s = append(s, "Max: "+fmt.Sprintf("%#v", this.Max)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Job) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&proto.Job{") + s = append(s, "Id: "+fmt.Sprintf("%#v", this.Id)+",\n") + s = append(s, "Partition: "+fmt.Sprintf("%#v", this.Partition)+",\n") + if this.Offsets != nil { + s = append(s, "Offsets: "+fmt.Sprintf("%#v", this.Offsets)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringBlockbuilder(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// BlockBuilderServiceClient is the client API for BlockBuilderService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type BlockBuilderServiceClient interface { + // GetJob requests a new job from the scheduler + GetJob(ctx context.Context, in *GetJobRequest, opts ...grpc.CallOption) (*GetJobResponse, error) + // CompleteJob notifies the scheduler that a job has been completed + CompleteJob(ctx context.Context, in *CompleteJobRequest, opts ...grpc.CallOption) (*CompleteJobResponse, error) + // SyncJob syncs job state with the scheduler + SyncJob(ctx context.Context, in *SyncJobRequest, opts ...grpc.CallOption) (*SyncJobResponse, error) +} + +type blockBuilderServiceClient struct { + cc *grpc.ClientConn +} + +func NewBlockBuilderServiceClient(cc *grpc.ClientConn) BlockBuilderServiceClient { + return &blockBuilderServiceClient{cc} +} + +func (c *blockBuilderServiceClient) GetJob(ctx context.Context, in *GetJobRequest, opts ...grpc.CallOption) (*GetJobResponse, error) { + out := new(GetJobResponse) + err := c.cc.Invoke(ctx, "/blockbuilder.types.BlockBuilderService/GetJob", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *blockBuilderServiceClient) CompleteJob(ctx context.Context, in *CompleteJobRequest, opts ...grpc.CallOption) (*CompleteJobResponse, error) { + out := new(CompleteJobResponse) + err := c.cc.Invoke(ctx, "/blockbuilder.types.BlockBuilderService/CompleteJob", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *blockBuilderServiceClient) SyncJob(ctx context.Context, in *SyncJobRequest, opts ...grpc.CallOption) (*SyncJobResponse, error) { + out := new(SyncJobResponse) + err := c.cc.Invoke(ctx, "/blockbuilder.types.BlockBuilderService/SyncJob", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// BlockBuilderServiceServer is the server API for BlockBuilderService service. +type BlockBuilderServiceServer interface { + // GetJob requests a new job from the scheduler + GetJob(context.Context, *GetJobRequest) (*GetJobResponse, error) + // CompleteJob notifies the scheduler that a job has been completed + CompleteJob(context.Context, *CompleteJobRequest) (*CompleteJobResponse, error) + // SyncJob syncs job state with the scheduler + SyncJob(context.Context, *SyncJobRequest) (*SyncJobResponse, error) +} + +// UnimplementedBlockBuilderServiceServer can be embedded to have forward compatible implementations. +type UnimplementedBlockBuilderServiceServer struct { +} + +func (*UnimplementedBlockBuilderServiceServer) GetJob(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetJob not implemented") +} +func (*UnimplementedBlockBuilderServiceServer) CompleteJob(ctx context.Context, req *CompleteJobRequest) (*CompleteJobResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CompleteJob not implemented") +} +func (*UnimplementedBlockBuilderServiceServer) SyncJob(ctx context.Context, req *SyncJobRequest) (*SyncJobResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SyncJob not implemented") +} + +func RegisterBlockBuilderServiceServer(s *grpc.Server, srv BlockBuilderServiceServer) { + s.RegisterService(&_BlockBuilderService_serviceDesc, srv) +} + +func _BlockBuilderService_GetJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetJobRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BlockBuilderServiceServer).GetJob(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/blockbuilder.types.BlockBuilderService/GetJob", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BlockBuilderServiceServer).GetJob(ctx, req.(*GetJobRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _BlockBuilderService_CompleteJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CompleteJobRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BlockBuilderServiceServer).CompleteJob(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/blockbuilder.types.BlockBuilderService/CompleteJob", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BlockBuilderServiceServer).CompleteJob(ctx, req.(*CompleteJobRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _BlockBuilderService_SyncJob_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SyncJobRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BlockBuilderServiceServer).SyncJob(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/blockbuilder.types.BlockBuilderService/SyncJob", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BlockBuilderServiceServer).SyncJob(ctx, req.(*SyncJobRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _BlockBuilderService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "blockbuilder.types.BlockBuilderService", + HandlerType: (*BlockBuilderServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetJob", + Handler: _BlockBuilderService_GetJob_Handler, + }, + { + MethodName: "CompleteJob", + Handler: _BlockBuilderService_CompleteJob_Handler, + }, + { + MethodName: "SyncJob", + Handler: _BlockBuilderService_SyncJob_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pkg/blockbuilder/types/proto/blockbuilder.proto", +} + +func (m *GetJobRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetJobRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetJobRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BuilderId) > 0 { + i -= len(m.BuilderId) + copy(dAtA[i:], m.BuilderId) + i = encodeVarintBlockbuilder(dAtA, i, uint64(len(m.BuilderId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetJobResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetJobResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetJobResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Ok { + i-- + if m.Ok { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.Job != nil { + { + size, err := m.Job.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBlockbuilder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CompleteJobRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompleteJobRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompleteJobRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Job != nil { + { + size, err := m.Job.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBlockbuilder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BuilderId) > 0 { + i -= len(m.BuilderId) + copy(dAtA[i:], m.BuilderId) + i = encodeVarintBlockbuilder(dAtA, i, uint64(len(m.BuilderId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CompleteJobResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CompleteJobResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CompleteJobResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *SyncJobRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SyncJobRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SyncJobRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Job != nil { + { + size, err := m.Job.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBlockbuilder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BuilderId) > 0 { + i -= len(m.BuilderId) + copy(dAtA[i:], m.BuilderId) + i = encodeVarintBlockbuilder(dAtA, i, uint64(len(m.BuilderId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SyncJobResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SyncJobResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SyncJobResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *Offsets) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Offsets) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Offsets) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Max != 0 { + i = encodeVarintBlockbuilder(dAtA, i, uint64(m.Max)) + i-- + dAtA[i] = 0x10 + } + if m.Min != 0 { + i = encodeVarintBlockbuilder(dAtA, i, uint64(m.Min)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Job) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Job) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Job) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Offsets != nil { + { + size, err := m.Offsets.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBlockbuilder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Partition != 0 { + i = encodeVarintBlockbuilder(dAtA, i, uint64(m.Partition)) + i-- + dAtA[i] = 0x10 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintBlockbuilder(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintBlockbuilder(dAtA []byte, offset int, v uint64) int { + offset -= sovBlockbuilder(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GetJobRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BuilderId) + if l > 0 { + n += 1 + l + sovBlockbuilder(uint64(l)) + } + return n +} + +func (m *GetJobResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Job != nil { + l = m.Job.Size() + n += 1 + l + sovBlockbuilder(uint64(l)) + } + if m.Ok { + n += 2 + } + return n +} + +func (m *CompleteJobRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BuilderId) + if l > 0 { + n += 1 + l + sovBlockbuilder(uint64(l)) + } + if m.Job != nil { + l = m.Job.Size() + n += 1 + l + sovBlockbuilder(uint64(l)) + } + return n +} + +func (m *CompleteJobResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *SyncJobRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BuilderId) + if l > 0 { + n += 1 + l + sovBlockbuilder(uint64(l)) + } + if m.Job != nil { + l = m.Job.Size() + n += 1 + l + sovBlockbuilder(uint64(l)) + } + return n +} + +func (m *SyncJobResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *Offsets) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Min != 0 { + n += 1 + sovBlockbuilder(uint64(m.Min)) + } + if m.Max != 0 { + n += 1 + sovBlockbuilder(uint64(m.Max)) + } + return n +} + +func (m *Job) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovBlockbuilder(uint64(l)) + } + if m.Partition != 0 { + n += 1 + sovBlockbuilder(uint64(m.Partition)) + } + if m.Offsets != nil { + l = m.Offsets.Size() + n += 1 + l + sovBlockbuilder(uint64(l)) + } + return n +} + +func sovBlockbuilder(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozBlockbuilder(x uint64) (n int) { + return sovBlockbuilder(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *GetJobRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&GetJobRequest{`, + `BuilderId:` + fmt.Sprintf("%v", this.BuilderId) + `,`, + `}`, + }, "") + return s +} +func (this *GetJobResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&GetJobResponse{`, + `Job:` + strings.Replace(this.Job.String(), "Job", "Job", 1) + `,`, + `Ok:` + fmt.Sprintf("%v", this.Ok) + `,`, + `}`, + }, "") + return s +} +func (this *CompleteJobRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&CompleteJobRequest{`, + `BuilderId:` + fmt.Sprintf("%v", this.BuilderId) + `,`, + `Job:` + strings.Replace(this.Job.String(), "Job", "Job", 1) + `,`, + `}`, + }, "") + return s +} +func (this *CompleteJobResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&CompleteJobResponse{`, + `}`, + }, "") + return s +} +func (this *SyncJobRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SyncJobRequest{`, + `BuilderId:` + fmt.Sprintf("%v", this.BuilderId) + `,`, + `Job:` + strings.Replace(this.Job.String(), "Job", "Job", 1) + `,`, + `}`, + }, "") + return s +} +func (this *SyncJobResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SyncJobResponse{`, + `}`, + }, "") + return s +} +func (this *Offsets) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Offsets{`, + `Min:` + fmt.Sprintf("%v", this.Min) + `,`, + `Max:` + fmt.Sprintf("%v", this.Max) + `,`, + `}`, + }, "") + return s +} +func (this *Job) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Job{`, + `Id:` + fmt.Sprintf("%v", this.Id) + `,`, + `Partition:` + fmt.Sprintf("%v", this.Partition) + `,`, + `Offsets:` + strings.Replace(this.Offsets.String(), "Offsets", "Offsets", 1) + `,`, + `}`, + }, "") + return s +} +func valueToStringBlockbuilder(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *GetJobRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetJobRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetJobRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BuilderId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BuilderId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetJobResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetJobResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetJobResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Job", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Job == nil { + m.Job = &Job{} + } + if err := m.Job.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ok", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ok = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompleteJobRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompleteJobRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompleteJobRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BuilderId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BuilderId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Job", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Job == nil { + m.Job = &Job{} + } + if err := m.Job.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CompleteJobResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CompleteJobResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CompleteJobResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SyncJobRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SyncJobRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SyncJobRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BuilderId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BuilderId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Job", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Job == nil { + m.Job = &Job{} + } + if err := m.Job.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SyncJobResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SyncJobResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SyncJobResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Offsets) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Offsets: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Offsets: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) + } + m.Min = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Min |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) + } + m.Max = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Max |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Job) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Job: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Job: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Partition", wireType) + } + m.Partition = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Partition |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Offsets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBlockbuilder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBlockbuilder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Offsets == nil { + m.Offsets = &Offsets{} + } + if err := m.Offsets.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBlockbuilder(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthBlockbuilder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipBlockbuilder(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthBlockbuilder + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthBlockbuilder + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBlockbuilder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipBlockbuilder(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthBlockbuilder + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthBlockbuilder = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowBlockbuilder = fmt.Errorf("proto: integer overflow") +) diff --git a/pkg/blockbuilder/types/proto/blockbuilder.proto b/pkg/blockbuilder/types/proto/blockbuilder.proto new file mode 100644 index 0000000000000..89811989b821c --- /dev/null +++ b/pkg/blockbuilder/types/proto/blockbuilder.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; + +package blockbuilder.types; + +option go_package = "github.com/grafana/loki/pkg/blockbuilder/types/proto"; + +// BlockBuilderService defines the gRPC service for block builder communication +service BlockBuilderService { + // GetJob requests a new job from the scheduler + rpc GetJob(GetJobRequest) returns (GetJobResponse) {} + // CompleteJob notifies the scheduler that a job has been completed + rpc CompleteJob(CompleteJobRequest) returns (CompleteJobResponse) {} + // SyncJob syncs job state with the scheduler + rpc SyncJob(SyncJobRequest) returns (SyncJobResponse) {} +} + +// GetJobRequest represents a request for a new job +message GetJobRequest { + string builder_id = 1; +} + +// GetJobResponse contains the response for a job request +message GetJobResponse { + Job job = 1; + bool ok = 2; +} + +// CompleteJobRequest represents a job completion notification +message CompleteJobRequest { + string builder_id = 1; + Job job = 2; +} + +// CompleteJobResponse is an empty response for job completion +message CompleteJobResponse {} + +// SyncJobRequest represents a job sync request +message SyncJobRequest { + string builder_id = 1; + Job job = 2; +} + +// SyncJobResponse is an empty response for job sync +message SyncJobResponse {} + +// Offsets represents the start and end offsets for a job +message Offsets { + int64 min = 1; + int64 max = 2; +} + +// Job represents a block building job +message Job { + string id = 1; + int32 partition = 2; + Offsets offsets = 3; +} diff --git a/pkg/blockbuilder/builder/transport.go b/pkg/blockbuilder/types/transport.go similarity index 66% rename from pkg/blockbuilder/builder/transport.go rename to pkg/blockbuilder/types/transport.go index ae498459cb667..5659ffb48a4b4 100644 --- a/pkg/blockbuilder/builder/transport.go +++ b/pkg/blockbuilder/types/transport.go @@ -1,58 +1,56 @@ -package builder +package types import ( "context" - - "github.com/grafana/loki/v3/pkg/blockbuilder/types" ) var ( - _ types.Transport = unimplementedTransport{} - _ types.Transport = &MemoryTransport{} + _ Transport = unimplementedTransport{} + _ Transport = &MemoryTransport{} ) // unimplementedTransport provides default implementations that panic type unimplementedTransport struct{} -func (t unimplementedTransport) SendGetJobRequest(_ context.Context, _ *types.GetJobRequest) (*types.GetJobResponse, error) { +func (t unimplementedTransport) SendGetJobRequest(_ context.Context, _ *GetJobRequest) (*GetJobResponse, error) { panic("unimplemented") } -func (t unimplementedTransport) SendCompleteJob(_ context.Context, _ *types.CompleteJobRequest) error { +func (t unimplementedTransport) SendCompleteJob(_ context.Context, _ *CompleteJobRequest) error { panic("unimplemented") } -func (t unimplementedTransport) SendSyncJob(_ context.Context, _ *types.SyncJobRequest) error { +func (t unimplementedTransport) SendSyncJob(_ context.Context, _ *SyncJobRequest) error { panic("unimplemented") } // MemoryTransport implements Transport interface for in-memory communication type MemoryTransport struct { - scheduler types.Scheduler + scheduler Scheduler } // NewMemoryTransport creates a new in-memory transport instance -func NewMemoryTransport(scheduler types.Scheduler) *MemoryTransport { +func NewMemoryTransport(scheduler Scheduler) *MemoryTransport { return &MemoryTransport{ scheduler: scheduler, } } -func (t *MemoryTransport) SendGetJobRequest(ctx context.Context, req *types.GetJobRequest) (*types.GetJobResponse, error) { +func (t *MemoryTransport) SendGetJobRequest(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error) { job, ok, err := t.scheduler.HandleGetJob(ctx, req.BuilderID) if err != nil { return nil, err } - return &types.GetJobResponse{ + return &GetJobResponse{ Job: job, OK: ok, }, nil } -func (t *MemoryTransport) SendCompleteJob(ctx context.Context, req *types.CompleteJobRequest) error { +func (t *MemoryTransport) SendCompleteJob(ctx context.Context, req *CompleteJobRequest) error { return t.scheduler.HandleCompleteJob(ctx, req.BuilderID, req.Job) } -func (t *MemoryTransport) SendSyncJob(ctx context.Context, req *types.SyncJobRequest) error { +func (t *MemoryTransport) SendSyncJob(ctx context.Context, req *SyncJobRequest) error { return t.scheduler.HandleSyncJob(ctx, req.BuilderID, req.Job) }