update agent job count type (#835)
* udpate agent job count type * generated protobuf * move object slice * license * errs --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1242,7 +1242,7 @@ type UpdateWorkerStatus struct {
|
||||
Status *WorkerStatus `protobuf:"varint,1,opt,name=status,proto3,enum=livekit.WorkerStatus,oneof" json:"status,omitempty"`
|
||||
// optional string metadata = 2 [deprecated=true];
|
||||
Load float32 `protobuf:"fixed32,3,opt,name=load,proto3" json:"load,omitempty"`
|
||||
JobCount int32 `protobuf:"varint,4,opt,name=job_count,json=jobCount,proto3" json:"job_count,omitempty"`
|
||||
JobCount uint32 `protobuf:"varint,4,opt,name=job_count,json=jobCount,proto3" json:"job_count,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UpdateWorkerStatus) Reset() {
|
||||
@@ -1291,7 +1291,7 @@ func (x *UpdateWorkerStatus) GetLoad() float32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UpdateWorkerStatus) GetJobCount() int32 {
|
||||
func (x *UpdateWorkerStatus) GetJobCount() uint32 {
|
||||
if x != nil {
|
||||
return x.JobCount
|
||||
}
|
||||
@@ -1590,7 +1590,7 @@ var file_livekit_agent_proto_rawDesc = []byte{
|
||||
0x6f, 0x72, 0x6b, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73,
|
||||
0x74, 0x61, 0x74, 0x75, 0x73, 0x88, 0x01, 0x01, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x61, 0x64,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x04, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1b, 0x0a, 0x09,
|
||||
0x6a, 0x6f, 0x62, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x6a, 0x6f, 0x62, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52,
|
||||
0x08, 0x6a, 0x6f, 0x62, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x73, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x22, 0x64, 0x0a, 0x0d, 0x4a, 0x6f, 0x62, 0x41, 0x73, 0x73, 0x69, 0x67,
|
||||
0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x03, 0x6a, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01,
|
||||
|
||||
34
logger/objectslice.go
Normal file
34
logger/objectslice.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2023 LiveKit, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logger
|
||||
|
||||
import (
|
||||
"go.uber.org/multierr"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
func ObjectSlice[T zapcore.ObjectMarshaler](s []T) zapcore.ArrayMarshaler {
|
||||
return objectSlice[T](s)
|
||||
}
|
||||
|
||||
type objectSlice[T zapcore.ObjectMarshaler] []T
|
||||
|
||||
func (a objectSlice[T]) MarshalLogArray(e zapcore.ArrayEncoder) error {
|
||||
var err error
|
||||
for _, o := range a {
|
||||
err = multierr.Append(err, e.AppendObject(o))
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (p protoListMarshaller) MarshalLogArray(e zapcore.ArrayEncoder) error {
|
||||
case protoreflect.BoolKind:
|
||||
e.AppendBool(v.Bool())
|
||||
case protoreflect.EnumKind:
|
||||
e.AppendInt32(int32(v.Enum()))
|
||||
e.AppendString(marshalProtoEnum(p.f, v))
|
||||
case protoreflect.Int32Kind, protoreflect.Int64Kind, protoreflect.Sint32Kind, protoreflect.Sint64Kind, protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind:
|
||||
e.AppendInt64(v.Int())
|
||||
case protoreflect.Uint32Kind, protoreflect.Uint64Kind, protoreflect.Fixed32Kind, protoreflect.Fixed64Kind:
|
||||
@@ -122,9 +122,7 @@ func marshalProtoField(k string, f protoreflect.FieldDescriptor, v protoreflect.
|
||||
e.AddBool(k, b)
|
||||
}
|
||||
case protoreflect.EnumKind:
|
||||
if n := v.Enum(); n != 0 {
|
||||
e.AddInt32(k, int32(n))
|
||||
}
|
||||
e.AddString(k, marshalProtoEnum(f, v))
|
||||
case protoreflect.Int32Kind, protoreflect.Int64Kind, protoreflect.Sint32Kind, protoreflect.Sint64Kind, protoreflect.Sfixed32Kind, protoreflect.Sfixed64Kind:
|
||||
if n := v.Int(); n != 0 {
|
||||
e.AddInt64(k, n)
|
||||
@@ -152,6 +150,13 @@ func marshalProtoField(k string, f protoreflect.FieldDescriptor, v protoreflect.
|
||||
}
|
||||
}
|
||||
|
||||
func marshalProtoEnum(f protoreflect.FieldDescriptor, v protoreflect.Value) string {
|
||||
if e := f.Enum().Values().ByNumber(v.Enum()); e != nil {
|
||||
return string(e.Name())
|
||||
}
|
||||
return fmt.Sprintf("<UNDEFINED(%d)>", v.Enum())
|
||||
}
|
||||
|
||||
func marshalProtoBytes(b []byte) string {
|
||||
n := len(b)
|
||||
if n > 64 {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package zaputil
|
||||
|
||||
import "go.uber.org/zap/zapcore"
|
||||
|
||||
func ObjectSlice[T zapcore.ObjectMarshaler](s []T) zapcore.ArrayMarshaler {
|
||||
return objectSlice[T](s)
|
||||
}
|
||||
|
||||
type objectSlice[T zapcore.ObjectMarshaler] []T
|
||||
|
||||
func (a objectSlice[T]) MarshalLogArray(e zapcore.ArrayEncoder) error {
|
||||
for _, o := range a {
|
||||
e.AppendObject(o)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -39,7 +39,7 @@ message JobState {
|
||||
int64 started_at = 3;
|
||||
int64 ended_at = 4;
|
||||
int64 updated_at = 5;
|
||||
string participant_identity = 6;
|
||||
string participant_identity = 6;
|
||||
}
|
||||
|
||||
// from Worker to Server
|
||||
@@ -163,7 +163,7 @@ message UpdateWorkerStatus {
|
||||
optional WorkerStatus status = 1;
|
||||
// optional string metadata = 2 [deprecated=true];
|
||||
float load = 3;
|
||||
int32 job_count = 4;
|
||||
uint32 job_count = 4;
|
||||
}
|
||||
|
||||
message JobAssignment {
|
||||
|
||||
Reference in New Issue
Block a user