diff --git a/ChangeLog b/ChangeLog index 3f26da13..ea0c8457 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Version 11.11.0 +--------------- + * Add a gRPC API to Lucidity which can be used to programmatically retrieve workers + * Mettle workers now report the hostname they're running on to Lucidity + Version 11.10.6 --------------- * Fix Elan's List endpoint to return true size for compressed blobs. diff --git a/VERSION b/VERSION index 12072506..4b8f5876 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.10.6 +11.11.0 diff --git a/lucidity/rpc/BUILD b/lucidity/rpc/BUILD index 80f0ae77..fb18db14 100644 --- a/lucidity/rpc/BUILD +++ b/lucidity/rpc/BUILD @@ -23,6 +23,7 @@ go_test( deps = [ ":rpc", "//proto/lucidity", + "///third_party/go/github.com_golang_protobuf//proto", "///third_party/go/github.com_stretchr_testify//assert", ], ) diff --git a/lucidity/rpc/rpc.go b/lucidity/rpc/rpc.go index 1781f3b3..d4083d31 100644 --- a/lucidity/rpc/rpc.go +++ b/lucidity/rpc/rpc.go @@ -7,6 +7,7 @@ import ( "mime" "net/http" "path" + "slices" "sync" "time" @@ -80,19 +81,44 @@ func newServer(minProportion float64) *server { } } -func (s *server) Update(ctx context.Context, req *pb.UpdateRequest) (*pb.UpdateResponse, error) { +func (s *server) Update(ctx context.Context, req *pb.Worker) (*pb.UpdateResponse, error) { req.UpdateTime = time.Now().Unix() v, ok := s.workers.Load(req.Name) - req.Disabled = ok && v.(*pb.UpdateRequest).Disabled + req.Disabled = ok && v.(*pb.Worker).Disabled s.workers.Store(req.Name, req) - if !ok || v.(*pb.UpdateRequest).Version != req.Version { + if !ok || v.(*pb.Worker).Version != req.Version { s.recalculateValidVersions() } s.checkWorkerHealth(req) return &pb.UpdateResponse{ShouldDisable: req.Disabled || !req.Healthy}, nil } -func (s *server) checkWorkerHealth(req *pb.UpdateRequest) { +func (s *server) ListWorkers(ctx context.Context, req *pb.ListWorkersRequest) (*pb.ListWorkersResponse, error) { + return s.listWorkers(req), nil +} + +func (s *server) listWorkers(req *pb.ListWorkersRequest) *pb.ListWorkersResponse { + workers := &pb.ListWorkersResponse{} + s.workers.Range(func(k, v interface{}) bool { + r := v.(*pb.Worker) + if (req.Hostname == "" || r.Hostname == req.Hostname) && (req.Name == "" || r.Name == req.Name) { + s.checkWorkerHealth(r) + workers.Workers = append(workers.Workers, r) + } + return true + }) + slices.SortFunc(workers.Workers, func(a, b *pb.Worker) int { + if a.Name < b.Name { + return -1 + } else if a.Name > b.Name { + return 1 + } + return 0 + }) + return workers +} + +func (s *server) checkWorkerHealth(req *pb.Worker) { if req.UpdateTime < time.Now().Add(-10*time.Minute).Unix() { req.Healthy = false req.Status = "Too long since last update" @@ -103,13 +129,7 @@ func (s *server) checkWorkerHealth(req *pb.UpdateRequest) { } func (s *server) ServeWorkers(w http.ResponseWriter, r *http.Request) { - workers := &pb.Workers{} - s.workers.Range(func(k, v interface{}) bool { - r := v.(*pb.UpdateRequest) - s.checkWorkerHealth(r) - workers.Workers = append(workers.Workers, r) - return true - }) + workers := s.listWorkers(&pb.ListWorkersRequest{}) m := jsonpb.Marshaler{ OrigName: true, Indent: " ", @@ -146,7 +166,7 @@ func (s *server) ServeDisable(w http.ResponseWriter, r *http.Request) { log.Warning("Request to disable unknown worker %s", req.Name) w.WriteHeader(http.StatusNotFound) } else { - v.(*pb.UpdateRequest).Disabled = req.Disable + v.(*pb.Worker).Disabled = req.Disable } } @@ -158,7 +178,7 @@ func (s *server) Clean(maxAge time.Duration) { for range time.NewTicker(maxAge / 10).C { min := time.Now().Add(-maxAge).Unix() s.workers.Range(func(k, v interface{}) bool { - if v.(*pb.UpdateRequest).UpdateTime < min { + if v.(*pb.Worker).UpdateTime < min { go s.removeWorker(k.(string)) } return true @@ -176,7 +196,7 @@ func (s *server) recalculateValidVersions() { counts := map[string]int{} n := 0 s.workers.Range(func(k, v interface{}) bool { - counts[v.(*pb.UpdateRequest).Version]++ + counts[v.(*pb.Worker).Version]++ n++ return true }) @@ -222,7 +242,7 @@ func (s *server) Describe(out chan<- *prometheus.Desc) { func (s *server) Collect(out chan<- prometheus.Metric) { var total, unhealthy, dead, busy float64 s.workers.Range(func(_, v interface{}) bool { - r := v.(*pb.UpdateRequest) + r := v.(*pb.Worker) s.checkWorkerHealth(r) if !r.Healthy { unhealthy++ diff --git a/lucidity/rpc/rpc_test.go b/lucidity/rpc/rpc_test.go index 8e0d3e4e..bd3c72f1 100644 --- a/lucidity/rpc/rpc_test.go +++ b/lucidity/rpc/rpc_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/golang/protobuf/proto" "github.com/stretchr/testify/assert" pb "github.com/thought-machine/please-servers/proto/lucidity" @@ -17,7 +18,7 @@ func TestValidVersion(t *testing.T) { // Helper function. Returns true if this update would trigger disabling the worker. update := func(name, version string) bool { - r, err := s.Update(context.Background(), &pb.UpdateRequest{ + r, err := s.Update(context.Background(), &pb.Worker{ Name: name, Version: version, Healthy: true, @@ -35,3 +36,34 @@ func TestValidVersion(t *testing.T) { assert.False(t, update("worker-1", "2.0")) // worker-1 has now updated and is alive again. assert.True(t, update("worker-3", "3.0")) // worker-3 has now updated beyond the others and it disables. } + +func TestListWorkers(t *testing.T) { + now := time.Now().Unix() + const version = "1.0" + s := newServer(1.0) + worker1 := &pb.Worker{ + Name: "worker-1", + Hostname: "hydrogen", + Version: version, + Healthy: true, + UpdateTime: now, + } + worker2 := &pb.Worker{ + Name: "worker-2", + Hostname: "helium", + Version: version, + Healthy: true, + UpdateTime: now, + } + s.Update(context.Background(), worker1) + s.Update(context.Background(), worker2) + resp, err := s.ListWorkers(context.Background(), &pb.ListWorkersRequest{}) + assert.NoError(t, err) + assert.Equal(t, 2, len(resp.Workers)) + assert.True(t, proto.Equal(worker1, resp.Workers[0])) + assert.True(t, proto.Equal(worker2, resp.Workers[1])) + resp, err = s.ListWorkers(context.Background(), &pb.ListWorkersRequest{Hostname: "helium"}) + assert.NoError(t, err) + assert.Equal(t, 1, len(resp.Workers)) + assert.True(t, proto.Equal(worker2, resp.Workers[0])) +} diff --git a/mettle/worker/reporting.go b/mettle/worker/reporting.go index 60e1af1c..e3c97937 100644 --- a/mettle/worker/reporting.go +++ b/mettle/worker/reporting.go @@ -3,6 +3,7 @@ package worker import ( "context" "fmt" + "os" "syscall" "time" @@ -16,7 +17,7 @@ import ( // If a Lucidity server hasn't been configured, calling this has no effect. func (w *worker) Report(healthy, busy, alive bool, status string, args ...interface{}) { if w.lucidChan != nil { - w.lucidChan <- &lpb.UpdateRequest{ + w.lucidChan <- &lpb.Worker{ Name: w.name, Version: w.version, StartTime: w.startTime.Unix(), @@ -41,11 +42,16 @@ func (w *worker) currentTaskID() string { // sendReports sends reports to Lucidity indefinitely. func (w *worker) sendReports() { + hostname, err := os.Hostname() + if err != nil { + log.Error("Failed to retrieve hostname: %s", err) + } t := time.NewTicker(5 * time.Minute) - var last *lpb.UpdateRequest + var last *lpb.Worker for { select { case report := <-w.lucidChan: + report.Hostname = hostname w.sendReport(report) last = report case <-t.C: @@ -56,7 +62,7 @@ func (w *worker) sendReports() { } } -func (w *worker) sendReport(report *lpb.UpdateRequest) { +func (w *worker) sendReport(report *lpb.Worker) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if resp, err := w.lucidity.Update(ctx, report); err != nil { diff --git a/mettle/worker/worker.go b/mettle/worker/worker.go index 0d8b509b..3f1da852 100644 --- a/mettle/worker/worker.go +++ b/mettle/worker/worker.go @@ -345,7 +345,7 @@ func initialiseWorker(instanceName, requestQueue, responseQueue, name, storage, } } if lucidity != "" { - w.lucidChan = make(chan *lpb.UpdateRequest, 100) + w.lucidChan = make(chan *lpb.Worker, 100) log.Notice("Dialling Lucidity...") conn, err := grpcutil.Dial(lucidity, true, "", tokenFile) // CA is currently not configurable. if err != nil { @@ -375,7 +375,7 @@ type worker struct { client elan.Client rclient *client.Client lucidity lpb.LucidityClient - lucidChan chan *lpb.UpdateRequest + lucidChan chan *lpb.Worker cache *ristretto.Cache instanceName string dir, rootDir string diff --git a/proto/lucidity/lucidity.pb.go b/proto/lucidity/lucidity.pb.go index 45cc1fab..f9a47a76 100644 --- a/proto/lucidity/lucidity.pb.go +++ b/proto/lucidity/lucidity.pb.go @@ -1,17 +1,12 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0 +// protoc-gen-go v1.33.0 // protoc v3.11.4 // source: proto/lucidity/lucidity.proto -package build_please_remote_lucidity +package lucidity import ( - context "context" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -25,17 +20,15 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type UpdateRequest struct { +type Worker struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The name of this worker. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The host name of the machine the worker is on + Hostname string `protobuf:"bytes,13,opt,name=hostname,proto3" json:"hostname,omitempty"` // The version this worker is currently at Version string `protobuf:"bytes,12,opt,name=version,proto3" json:"version,omitempty"` // The time the worker started at (as a Unix timestamp) @@ -61,8 +54,8 @@ type UpdateRequest struct { TaskStartTime int64 `protobuf:"varint,11,opt,name=task_start_time,json=taskStartTime,proto3" json:"task_start_time,omitempty"` } -func (x *UpdateRequest) Reset() { - *x = UpdateRequest{} +func (x *Worker) Reset() { + *x = Worker{} if protoimpl.UnsafeEnabled { mi := &file_proto_lucidity_lucidity_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -70,13 +63,13 @@ func (x *UpdateRequest) Reset() { } } -func (x *UpdateRequest) String() string { +func (x *Worker) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateRequest) ProtoMessage() {} +func (*Worker) ProtoMessage() {} -func (x *UpdateRequest) ProtoReflect() protoreflect.Message { +func (x *Worker) ProtoReflect() protoreflect.Message { mi := &file_proto_lucidity_lucidity_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -88,89 +81,96 @@ func (x *UpdateRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateRequest.ProtoReflect.Descriptor instead. -func (*UpdateRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use Worker.ProtoReflect.Descriptor instead. +func (*Worker) Descriptor() ([]byte, []int) { return file_proto_lucidity_lucidity_proto_rawDescGZIP(), []int{0} } -func (x *UpdateRequest) GetName() string { +func (x *Worker) GetName() string { if x != nil { return x.Name } return "" } -func (x *UpdateRequest) GetVersion() string { +func (x *Worker) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +func (x *Worker) GetVersion() string { if x != nil { return x.Version } return "" } -func (x *UpdateRequest) GetStartTime() int64 { +func (x *Worker) GetStartTime() int64 { if x != nil { return x.StartTime } return 0 } -func (x *UpdateRequest) GetUpdateTime() int64 { +func (x *Worker) GetUpdateTime() int64 { if x != nil { return x.UpdateTime } return 0 } -func (x *UpdateRequest) GetStatus() string { +func (x *Worker) GetStatus() string { if x != nil { return x.Status } return "" } -func (x *UpdateRequest) GetHealthy() bool { +func (x *Worker) GetHealthy() bool { if x != nil { return x.Healthy } return false } -func (x *UpdateRequest) GetBusy() bool { +func (x *Worker) GetBusy() bool { if x != nil { return x.Busy } return false } -func (x *UpdateRequest) GetAlive() bool { +func (x *Worker) GetAlive() bool { if x != nil { return x.Alive } return false } -func (x *UpdateRequest) GetLastTask() string { +func (x *Worker) GetLastTask() string { if x != nil { return x.LastTask } return "" } -func (x *UpdateRequest) GetDisabled() bool { +func (x *Worker) GetDisabled() bool { if x != nil { return x.Disabled } return false } -func (x *UpdateRequest) GetCurrentTask() string { +func (x *Worker) GetCurrentTask() string { if x != nil { return x.CurrentTask } return "" } -func (x *UpdateRequest) GetTaskStartTime() int64 { +func (x *Worker) GetTaskStartTime() int64 { if x != nil { return x.TaskStartTime } @@ -226,18 +226,19 @@ func (x *UpdateResponse) GetShouldDisable() bool { return false } -// This is not part of the actual RPC API but is used to serve from HTTP. -type Workers struct { +type ListWorkersRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // List of all the currently known workers. - Workers []*UpdateRequest `protobuf:"bytes,1,rep,name=workers,proto3" json:"workers,omitempty"` + // The worker name to return + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The hostname to return workers for + Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` } -func (x *Workers) Reset() { - *x = Workers{} +func (x *ListWorkersRequest) Reset() { + *x = ListWorkersRequest{} if protoimpl.UnsafeEnabled { mi := &file_proto_lucidity_lucidity_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -245,13 +246,13 @@ func (x *Workers) Reset() { } } -func (x *Workers) String() string { +func (x *ListWorkersRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Workers) ProtoMessage() {} +func (*ListWorkersRequest) ProtoMessage() {} -func (x *Workers) ProtoReflect() protoreflect.Message { +func (x *ListWorkersRequest) ProtoReflect() protoreflect.Message { mi := &file_proto_lucidity_lucidity_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -263,12 +264,68 @@ func (x *Workers) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Workers.ProtoReflect.Descriptor instead. -func (*Workers) Descriptor() ([]byte, []int) { +// Deprecated: Use ListWorkersRequest.ProtoReflect.Descriptor instead. +func (*ListWorkersRequest) Descriptor() ([]byte, []int) { return file_proto_lucidity_lucidity_proto_rawDescGZIP(), []int{2} } -func (x *Workers) GetWorkers() []*UpdateRequest { +func (x *ListWorkersRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ListWorkersRequest) GetHostname() string { + if x != nil { + return x.Hostname + } + return "" +} + +type ListWorkersResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // List of all the currently known workers, optionally filtered on the + // request. + Workers []*Worker `protobuf:"bytes,1,rep,name=workers,proto3" json:"workers,omitempty"` +} + +func (x *ListWorkersResponse) Reset() { + *x = ListWorkersResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_lucidity_lucidity_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListWorkersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListWorkersResponse) ProtoMessage() {} + +func (x *ListWorkersResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_lucidity_lucidity_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListWorkersResponse.ProtoReflect.Descriptor instead. +func (*ListWorkersResponse) Descriptor() ([]byte, []int) { + return file_proto_lucidity_lucidity_proto_rawDescGZIP(), []int{3} +} + +func (x *ListWorkersResponse) GetWorkers() []*Worker { if x != nil { return x.Workers } @@ -290,7 +347,7 @@ type Disable struct { func (x *Disable) Reset() { *x = Disable{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lucidity_lucidity_proto_msgTypes[3] + mi := &file_proto_lucidity_lucidity_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -303,7 +360,7 @@ func (x *Disable) String() string { func (*Disable) ProtoMessage() {} func (x *Disable) ProtoReflect() protoreflect.Message { - mi := &file_proto_lucidity_lucidity_proto_msgTypes[3] + mi := &file_proto_lucidity_lucidity_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -316,7 +373,7 @@ func (x *Disable) ProtoReflect() protoreflect.Message { // Deprecated: Use Disable.ProtoReflect.Descriptor instead. func (*Disable) Descriptor() ([]byte, []int) { - return file_proto_lucidity_lucidity_proto_rawDescGZIP(), []int{3} + return file_proto_lucidity_lucidity_proto_rawDescGZIP(), []int{4} } func (x *Disable) GetName() string { @@ -339,49 +396,66 @@ var file_proto_lucidity_lucidity_proto_rawDesc = []byte{ 0x0a, 0x1d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2f, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, - 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x22, 0xdd, 0x02, - 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 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, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, - 0x12, 0x0a, 0x04, 0x62, 0x75, 0x73, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x62, - 0x75, 0x73, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x61, 0x73, - 0x74, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x61, - 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x61, - 0x73, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, - 0x74, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x37, 0x0a, - 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x25, 0x0a, 0x0e, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x5f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x44, - 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x50, 0x0a, 0x07, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, - 0x73, 0x12, 0x45, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, - 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x22, 0xf2, 0x02, + 0x0a, 0x06, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, + 0x61, 0x6c, 0x74, 0x68, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x68, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x75, 0x73, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x04, 0x62, 0x75, 0x73, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x61, + 0x73, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x61, 0x73, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, + 0x6d, 0x65, 0x22, 0x37, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x5f, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x68, + 0x6f, 0x75, 0x6c, 0x64, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x44, 0x0a, 0x12, 0x4c, + 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 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, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x55, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, + 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, + 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x22, 0x37, 0x0a, 0x07, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, - 0x65, 0x32, 0x6f, 0x0a, 0x08, 0x4c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x12, 0x63, 0x0a, - 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2b, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, - 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, - 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, - 0x69, 0x74, 0x79, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x32, 0xdc, 0x01, 0x0a, 0x08, 0x4c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x12, 0x5c, + 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, + 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x1a, 0x2c, + 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, + 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x0b, + 0x4c, 0x69, 0x73, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x12, 0x30, 0x2e, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, + 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x57, + 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, + 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x70, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6d, + 0x6f, 0x74, 0x65, 0x2e, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, + 0x68, 0x6f, 0x75, 0x67, 0x68, 0x74, 0x2d, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x70, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x75, 0x63, 0x69, 0x64, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -396,19 +470,22 @@ func file_proto_lucidity_lucidity_proto_rawDescGZIP() []byte { return file_proto_lucidity_lucidity_proto_rawDescData } -var file_proto_lucidity_lucidity_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_lucidity_lucidity_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_proto_lucidity_lucidity_proto_goTypes = []interface{}{ - (*UpdateRequest)(nil), // 0: build.please.remote.lucidity.UpdateRequest - (*UpdateResponse)(nil), // 1: build.please.remote.lucidity.UpdateResponse - (*Workers)(nil), // 2: build.please.remote.lucidity.Workers - (*Disable)(nil), // 3: build.please.remote.lucidity.Disable + (*Worker)(nil), // 0: build.please.remote.lucidity.Worker + (*UpdateResponse)(nil), // 1: build.please.remote.lucidity.UpdateResponse + (*ListWorkersRequest)(nil), // 2: build.please.remote.lucidity.ListWorkersRequest + (*ListWorkersResponse)(nil), // 3: build.please.remote.lucidity.ListWorkersResponse + (*Disable)(nil), // 4: build.please.remote.lucidity.Disable } var file_proto_lucidity_lucidity_proto_depIdxs = []int32{ - 0, // 0: build.please.remote.lucidity.Workers.workers:type_name -> build.please.remote.lucidity.UpdateRequest - 0, // 1: build.please.remote.lucidity.Lucidity.Update:input_type -> build.please.remote.lucidity.UpdateRequest - 1, // 2: build.please.remote.lucidity.Lucidity.Update:output_type -> build.please.remote.lucidity.UpdateResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 0, // 0: build.please.remote.lucidity.ListWorkersResponse.workers:type_name -> build.please.remote.lucidity.Worker + 0, // 1: build.please.remote.lucidity.Lucidity.Update:input_type -> build.please.remote.lucidity.Worker + 2, // 2: build.please.remote.lucidity.Lucidity.ListWorkers:input_type -> build.please.remote.lucidity.ListWorkersRequest + 1, // 3: build.please.remote.lucidity.Lucidity.Update:output_type -> build.please.remote.lucidity.UpdateResponse + 3, // 4: build.please.remote.lucidity.Lucidity.ListWorkers:output_type -> build.please.remote.lucidity.ListWorkersResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] 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 @@ -421,7 +498,7 @@ func file_proto_lucidity_lucidity_proto_init() { } if !protoimpl.UnsafeEnabled { file_proto_lucidity_lucidity_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateRequest); i { + switch v := v.(*Worker); i { case 0: return &v.state case 1: @@ -445,7 +522,7 @@ func file_proto_lucidity_lucidity_proto_init() { } } file_proto_lucidity_lucidity_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Workers); i { + switch v := v.(*ListWorkersRequest); i { case 0: return &v.state case 1: @@ -457,6 +534,18 @@ func file_proto_lucidity_lucidity_proto_init() { } } file_proto_lucidity_lucidity_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListWorkersResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_lucidity_lucidity_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Disable); i { case 0: return &v.state @@ -475,7 +564,7 @@ func file_proto_lucidity_lucidity_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_lucidity_lucidity_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, @@ -488,85 +577,3 @@ func file_proto_lucidity_lucidity_proto_init() { file_proto_lucidity_lucidity_proto_goTypes = nil file_proto_lucidity_lucidity_proto_depIdxs = nil } - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// 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.SupportPackageIsVersion6 - -// LucidityClient is the client API for Lucidity service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type LucidityClient interface { - // Update sends the server an update on the current state of a worker. - Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) -} - -type lucidityClient struct { - cc grpc.ClientConnInterface -} - -func NewLucidityClient(cc grpc.ClientConnInterface) LucidityClient { - return &lucidityClient{cc} -} - -func (c *lucidityClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) { - out := new(UpdateResponse) - err := c.cc.Invoke(ctx, "/build.please.remote.lucidity.Lucidity/Update", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// LucidityServer is the server API for Lucidity service. -type LucidityServer interface { - // Update sends the server an update on the current state of a worker. - Update(context.Context, *UpdateRequest) (*UpdateResponse, error) -} - -// UnimplementedLucidityServer can be embedded to have forward compatible implementations. -type UnimplementedLucidityServer struct { -} - -func (*UnimplementedLucidityServer) Update(context.Context, *UpdateRequest) (*UpdateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") -} - -func RegisterLucidityServer(s *grpc.Server, srv LucidityServer) { - s.RegisterService(&_Lucidity_serviceDesc, srv) -} - -func _Lucidity_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LucidityServer).Update(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/build.please.remote.lucidity.Lucidity/Update", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LucidityServer).Update(ctx, req.(*UpdateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Lucidity_serviceDesc = grpc.ServiceDesc{ - ServiceName: "build.please.remote.lucidity.Lucidity", - HandlerType: (*LucidityServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Update", - Handler: _Lucidity_Update_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "proto/lucidity/lucidity.proto", -} diff --git a/proto/lucidity/lucidity.proto b/proto/lucidity/lucidity.proto index 801693c0..23d12695 100644 --- a/proto/lucidity/lucidity.proto +++ b/proto/lucidity/lucidity.proto @@ -8,12 +8,16 @@ option go_package = "github.com/thought-machine/please-servers/proto/lucidity"; // central server and send some basic information about their status. service Lucidity { // Update sends the server an update on the current state of a worker. - rpc Update(UpdateRequest) returns (UpdateResponse); + rpc Update(Worker) returns (UpdateResponse); + // List the current set of workers + rpc ListWorkers(ListWorkersRequest) returns (ListWorkersResponse); } -message UpdateRequest { +message Worker { // The name of this worker. string name = 1; + // The host name of the machine the worker is on + string hostname = 13; // The version this worker is currently at string version = 12; // The time the worker started at (as a Unix timestamp) @@ -45,10 +49,17 @@ message UpdateResponse { bool should_disable = 1; } -// This is not part of the actual RPC API but is used to serve from HTTP. -message Workers { - // List of all the currently known workers. - repeated UpdateRequest workers = 1; +message ListWorkersRequest { + // The worker name to return + string name = 1; + // The hostname to return workers for + string hostname = 2; +} + +message ListWorkersResponse { + // List of all the currently known workers, optionally filtered on the + // request. + repeated Worker workers = 1; } // This is part of the HTTP API; the request to disable a worker. diff --git a/proto/lucidity/lucidity_grpc.pb.go b/proto/lucidity/lucidity_grpc.pb.go new file mode 100644 index 00000000..8cc75515 --- /dev/null +++ b/proto/lucidity/lucidity_grpc.pb.go @@ -0,0 +1,141 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package lucidity + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// LucidityClient is the client API for Lucidity service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type LucidityClient interface { + // Update sends the server an update on the current state of a worker. + Update(ctx context.Context, in *Worker, opts ...grpc.CallOption) (*UpdateResponse, error) + // List the current set of workers + ListWorkers(ctx context.Context, in *ListWorkersRequest, opts ...grpc.CallOption) (*ListWorkersResponse, error) +} + +type lucidityClient struct { + cc grpc.ClientConnInterface +} + +func NewLucidityClient(cc grpc.ClientConnInterface) LucidityClient { + return &lucidityClient{cc} +} + +func (c *lucidityClient) Update(ctx context.Context, in *Worker, opts ...grpc.CallOption) (*UpdateResponse, error) { + out := new(UpdateResponse) + err := c.cc.Invoke(ctx, "/build.please.remote.lucidity.Lucidity/Update", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *lucidityClient) ListWorkers(ctx context.Context, in *ListWorkersRequest, opts ...grpc.CallOption) (*ListWorkersResponse, error) { + out := new(ListWorkersResponse) + err := c.cc.Invoke(ctx, "/build.please.remote.lucidity.Lucidity/ListWorkers", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LucidityServer is the server API for Lucidity service. +// All implementations must embed UnimplementedLucidityServer +// for forward compatibility +type LucidityServer interface { + // Update sends the server an update on the current state of a worker. + Update(context.Context, *Worker) (*UpdateResponse, error) + // List the current set of workers + ListWorkers(context.Context, *ListWorkersRequest) (*ListWorkersResponse, error) + mustEmbedUnimplementedLucidityServer() +} + +// UnimplementedLucidityServer must be embedded to have forward compatible implementations. +type UnimplementedLucidityServer struct { +} + +func (UnimplementedLucidityServer) Update(context.Context, *Worker) (*UpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") +} +func (UnimplementedLucidityServer) ListWorkers(context.Context, *ListWorkersRequest) (*ListWorkersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListWorkers not implemented") +} +func (UnimplementedLucidityServer) mustEmbedUnimplementedLucidityServer() {} + +// UnsafeLucidityServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to LucidityServer will +// result in compilation errors. +type UnsafeLucidityServer interface { + mustEmbedUnimplementedLucidityServer() +} + +func RegisterLucidityServer(s grpc.ServiceRegistrar, srv LucidityServer) { + s.RegisterService(&Lucidity_ServiceDesc, srv) +} + +func _Lucidity_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Worker) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LucidityServer).Update(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/build.please.remote.lucidity.Lucidity/Update", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LucidityServer).Update(ctx, req.(*Worker)) + } + return interceptor(ctx, in, info, handler) +} + +func _Lucidity_ListWorkers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListWorkersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LucidityServer).ListWorkers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/build.please.remote.lucidity.Lucidity/ListWorkers", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LucidityServer).ListWorkers(ctx, req.(*ListWorkersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Lucidity_ServiceDesc is the grpc.ServiceDesc for Lucidity service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Lucidity_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "build.please.remote.lucidity.Lucidity", + HandlerType: (*LucidityServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Update", + Handler: _Lucidity_Update_Handler, + }, + { + MethodName: "ListWorkers", + Handler: _Lucidity_ListWorkers_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/lucidity/lucidity.proto", +}