-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(scheduler): implement and register block builder rpc service #15248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
120bbf6
5dc05a3
848e4ec
990e328
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,10 @@ import ( | |
| "github.com/twmb/franz-go/pkg/kadm" | ||
|
|
||
| "github.com/grafana/loki/v3/pkg/blockbuilder/types" | ||
| "github.com/grafana/loki/v3/pkg/blockbuilder/types/proto" | ||
| ) | ||
|
|
||
| var ( | ||
| _ types.Scheduler = unimplementedScheduler{} | ||
| _ types.Scheduler = &BlockScheduler{} | ||
| ) | ||
|
|
||
|
|
@@ -140,7 +140,7 @@ func (s *BlockScheduler) HandleGetJob(ctx context.Context, builderID string) (*t | |
| case <-ctx.Done(): | ||
| return nil, false, ctx.Err() | ||
| default: | ||
| return s.queue.Dequeue(builderID) | ||
| return s.queue.Dequeue(ctx, builderID, false) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -155,17 +155,44 @@ func (s *BlockScheduler) HandleSyncJob(_ context.Context, builderID string, job | |
| return nil | ||
| } | ||
|
|
||
| // unimplementedScheduler provides default implementations that panic. | ||
| type unimplementedScheduler struct{} | ||
|
|
||
| func (s unimplementedScheduler) HandleGetJob(_ context.Context, _ string) (*types.Job, bool, error) { | ||
| panic("unimplemented") | ||
| func (s *BlockScheduler) CompleteJob(_ context.Context, req *proto.CompleteJobRequest) (*proto.CompleteJobResponse, error) { | ||
| s.queue.MarkComplete(req.Job.Id) | ||
| return nil, nil | ||
|
||
| } | ||
|
|
||
| func (s unimplementedScheduler) HandleCompleteJob(_ context.Context, _ string, _ *types.Job) error { | ||
| panic("unimplemented") | ||
| func (s *BlockScheduler) SyncJob(_ context.Context, req *proto.SyncJobRequest) (*proto.SyncJobResponse, error) { | ||
| s.queue.SyncJob(req.Job.Id, req.BuilderId, &types.Job{ | ||
| ID: req.Job.Id, | ||
| Partition: req.Job.Partition, | ||
| Offsets: types.Offsets{ | ||
| Min: req.Job.Offsets.Min, | ||
| Max: req.Job.Offsets.Max, | ||
| }, | ||
| }) | ||
|
|
||
| return nil, nil | ||
|
||
| } | ||
|
|
||
| func (s unimplementedScheduler) HandleSyncJob(_ context.Context, _ string, _ *types.Job) error { | ||
| panic("unimplemented") | ||
| func (s *BlockScheduler) GetJob(req *proto.GetJobRequest, stream proto.BlockBuilderService_GetJobServer) error { | ||
| job, ok, err := s.queue.Dequeue(stream.Context(), req.BuilderId, true) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| var jobpb *proto.Job | ||
| if ok { | ||
| jobpb = &proto.Job{ | ||
| Id: job.ID, | ||
| Partition: job.Partition, | ||
| Offsets: &proto.Offsets{ | ||
| Min: job.Offsets.Min, | ||
| Max: job.Offsets.Max, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| return stream.Send(&proto.GetJobResponse{ | ||
| Job: jobpb, | ||
| Ok: ok, | ||
| }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,12 @@ func (t *GRPCTransport) SendGetJobRequest(ctx context.Context, req *GetJobReques | |
| BuilderId: req.BuilderID, | ||
| } | ||
|
|
||
| resp, err := t.GetJob(ctx, protoReq) | ||
| client, err := t.GetJob(ctx, protoReq) | ||
|
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| resp, err := client.Recv() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -111,7 +116,7 @@ func protoToJob(p *proto.Job) *Job { | |
| } | ||
| return &Job{ | ||
| ID: p.GetId(), | ||
| Partition: int(p.GetPartition()), | ||
| Partition: p.GetPartition(), | ||
| Offsets: Offsets{ | ||
| Min: p.GetOffsets().GetMin(), | ||
| Max: p.GetOffsets().GetMax(), | ||
|
|
@@ -126,7 +131,7 @@ func jobToProto(j *Job) *proto.Job { | |
| } | ||
| return &proto.Job{ | ||
| Id: j.ID, | ||
| Partition: int32(j.Partition), | ||
| Partition: j.Partition, | ||
| Offsets: &proto.Offsets{ | ||
| Min: j.Offsets.Min, | ||
| Max: j.Offsets.Max, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.