diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5f921422..5284be15 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -146,7 +146,7 @@ jobs: cd tests docker compose -f env/docker-compose-temporal-updates.yaml up -d --remove-orphans - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./coverage-ci/rrt_upd.out -covermode=atomic ./updates + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./coverage-ci/rrt_upd.out -covermode=atomic ./updates docker compose -f env/docker-compose-temporal-updates.yaml up -d --remove-orphans @@ -224,22 +224,22 @@ jobs: - name: Run Temporal canceller module tests run: | - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./tests/coverage-ci/rrt_c.out -covermode=atomic ./canceller/... + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./tests/coverage-ci/rrt_c.out -covermode=atomic ./canceller/... - name: Run Temporal dataconverter module tests run: | - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./tests/coverage-ci/rrt_dc.out -covermode=atomic ./dataconverter/... + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./tests/coverage-ci/rrt_dc.out -covermode=atomic ./dataconverter/... - name: Run Temporal queue module tests run: | - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./tests/coverage-ci/rrt_q.out -covermode=atomic ./queue/... + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./tests/coverage-ci/rrt_q.out -covermode=atomic ./queue/... - name: Run Temporal tests with coverage run: | cd tests docker compose -f env/docker-compose-temporal.yaml up -d --remove-orphans - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./coverage-ci/rrt.out -covermode=atomic ./general + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./coverage-ci/rrt.out -covermode=atomic ./general docker compose -f env/docker-compose-temporal.yaml up -d --remove-orphans @@ -313,7 +313,7 @@ jobs: docker compose -f env/temporal_tls/docker-compose.yml up -d --remove-orphans sleep 60 - go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v5/... -coverprofile=./coverage-ci/rrt_tls.out -covermode=atomic ./tls + go test -timeout 20m -v -race -cover -tags=debug -failfast -coverpkg=github.com/temporalio/roadrunner-temporal/v6/... -coverprofile=./coverage-ci/rrt_tls.out -covermode=atomic ./tls docker compose -f env/temporal_tls/docker-compose.yml down @@ -342,8 +342,8 @@ jobs: tail -q -n +2 *.out >> summary.txt awk ' NR == 1 { print; next } - /^github\.com\/temporalio\/roadrunner-temporal\/v5\// { - sub(/^github\.com\/temporalio\/roadrunner-temporal\/v5\//, "", $0) + /^github\.com\/temporalio\/roadrunner-temporal\/v6\// { + sub(/^github\.com\/temporalio\/roadrunner-temporal\/v6\//, "", $0) print } ' summary.txt > summary.filtered.txt diff --git a/aggregatedpool/activity.go b/aggregatedpool/activity.go index 11c3102f..baf4883e 100644 --- a/aggregatedpool/activity.go +++ b/aggregatedpool/activity.go @@ -6,15 +6,16 @@ import ( "sync/atomic" "unsafe" + "log/slog" + "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/goridge/v3/pkg/frame" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/goridge/v4/pkg/frame" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" commonpb "go.temporal.io/api/common/v1" tActivity "go.temporal.io/sdk/activity" "go.temporal.io/sdk/temporal" - "go.uber.org/zap" ) const ( @@ -26,7 +27,7 @@ const ( type Activity struct { codec api.Codec pool api.Pool - log *zap.Logger + log *slog.Logger seqID uint64 running sync.Map @@ -34,7 +35,7 @@ type Activity struct { disableActivityWorkers bool } -func NewActivityDefinition(ac api.Codec, p api.Pool, log *zap.Logger, disableActivityWorkers bool) *Activity { +func NewActivityDefinition(ac api.Codec, p api.Pool, log *slog.Logger, disableActivityWorkers bool) *Activity { return &Activity{ log: log, codec: ac, diff --git a/aggregatedpool/handler.go b/aggregatedpool/handler.go index 3afce609..c8c4c719 100644 --- a/aggregatedpool/handler.go +++ b/aggregatedpool/handler.go @@ -8,14 +8,13 @@ import ( "time" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/goridge/v3/pkg/frame" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/goridge/v4/pkg/frame" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/internal" commonpb "go.temporal.io/api/common/v1" bindings "go.temporal.io/sdk/internalbindings" "go.temporal.io/sdk/temporal" "go.temporal.io/sdk/workflow" - "go.uber.org/zap" ) const ( @@ -38,7 +37,7 @@ func (wp *Workflow) getContext() *internal.Context { } func (wp *Workflow) handleUpdate(name string, id string, input *commonpb.Payloads, header *commonpb.Header, callbacks bindings.UpdateCallbacks) { - wp.log.Debug("update request received", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID), zap.String("name", name), zap.String("id", id)) + wp.log.Debug("update request received", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID, "name", name, "id", id) // save update name wp.updatesQueue[name] = struct{}{} @@ -48,7 +47,7 @@ func (wp *Workflow) handleUpdate(name string, id string, input *commonpb.Payload updatesQueueCb := func() { // validate callback wp.updateValidateCb[id] = func(msg *internal.Message) { - wp.log.Debug("validate request callback", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID), zap.String("name", name), zap.String("id", id), zap.Bool("is_replaying", wp.env.IsReplaying()), zap.Any("result", msg)) + wp.log.Debug("validate request callback", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID, "name", name, "id", id, "is_replaying", wp.env.IsReplaying(), "result", msg) if !wp.env.IsReplaying() { // before acceptance, we have only one option - reject if msg.Failure != nil { @@ -63,7 +62,7 @@ func (wp *Workflow) handleUpdate(name string, id string, input *commonpb.Payload // execute callback wp.updateCompleteCb[id] = func(msg *internal.Message) { - wp.log.Debug("update request callback", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID), zap.String("name", name), zap.String("id", id), zap.Any("result", msg)) + wp.log.Debug("update request callback", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID, "name", name, "id", id, "result", msg) if msg.Failure != nil { callbacks.Complete(nil, temporal.GetDefaultFailureConverter().FailureToError(msg.Failure)) return @@ -101,7 +100,7 @@ func (wp *Workflow) handleCancel() { // schedule the signal processing func (wp *Workflow) handleSignal(name string, input *commonpb.Payloads, header *commonpb.Header) error { - wp.log.Debug("signal request", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID), zap.String("name", name)) + wp.log.Debug("signal request", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID, "name", name) wp.mq.PushCommand( internal.InvokeSignal{ RunID: wp.env.WorkflowInfo().WorkflowExecution.RunID, @@ -119,7 +118,7 @@ func (wp *Workflow) handleSignal(name string, input *commonpb.Payloads, header * func (wp *Workflow) handleQuery(queryType string, queryArgs *commonpb.Payloads, header *commonpb.Header) (*commonpb.Payloads, error) { const op = errors.Op("workflow_process_handle_query") - wp.log.Debug("query request", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID), zap.String("name", queryType)) + wp.log.Debug("query request", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID, "name", queryType) result, err := wp.runCommand(internal.InvokeQuery{ RunID: wp.env.WorkflowInfo().WorkflowExecution.RunID, @@ -143,28 +142,28 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { switch command := msg.Command.(type) { case *internal.ExecuteActivity: - wp.log.Debug("activity request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("activity request", "ID", msg.ID) params := command.ActivityParams(wp.env, msg.Payloads, msg.Header) activityID := wp.env.ExecuteActivity(params, wp.createCallback(msg.ID, "activity")) wp.canceller.Register(msg.ID, func() error { - wp.log.Debug("registering activity canceller", zap.String("activityID", activityID.String())) + wp.log.Debug("registering activity canceller", "activityID", activityID.String()) wp.env.RequestCancelActivity(activityID) return nil }) case *internal.ExecuteLocalActivity: - wp.log.Debug("local activity request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("local activity request", "ID", msg.ID) params := command.LocalActivityParams(wp.env, wp.la, msg.Payloads, msg.Header) activityID := wp.env.ExecuteLocalActivity(params, wp.createLocalActivityCallback(msg.ID)) wp.canceller.Register(msg.ID, func() error { - wp.log.Debug("registering local activity canceller", zap.String("activityID", activityID.String())) + wp.log.Debug("registering local activity canceller", "activityID", activityID.String()) wp.env.RequestCancelLocalActivity(activityID) return nil }) case *internal.ExecuteChildWorkflow: - wp.log.Debug("execute child workflow request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("execute child workflow request", "ID", msg.ID) params := command.WorkflowParams(wp.env, msg.Payloads, msg.Header) // always use deterministic id @@ -183,7 +182,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { }) case *internal.GetChildWorkflowExecution: - wp.log.Debug("get child workflow execution request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("get child workflow execution request", "ID", msg.ID) wp.ids.Listen(command.ID, func(w bindings.WorkflowExecution, err error) { cl := wp.createCallback(msg.ID, "GetChildWorkflow") @@ -201,20 +200,20 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { }) case *internal.NewTimer: - wp.log.Debug("timer request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("timer request", "ID", msg.ID) timerID := wp.env.NewTimer(command.ToDuration(), workflow.TimerOptions{ Summary: command.Summary, }, wp.createCallback(msg.ID, "NewTimer")) wp.canceller.Register(msg.ID, func() error { if timerID != nil { - wp.log.Debug("cancel timer request", zap.String("timerID", timerID.String())) + wp.log.Debug("cancel timer request", "timerID", timerID.String()) wp.env.RequestCancelTimer(*timerID) } return nil }) case *internal.GetVersion: - wp.log.Debug("get version request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("get version request", "ID", msg.ID) version := wp.env.GetVersion( command.ChangeID, workflow.Version(command.MinSupported), @@ -233,7 +232,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } case *internal.SideEffect: - wp.log.Debug("side-effect request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("side-effect request", "ID", msg.ID) wp.env.SideEffect( func() (*commonpb.Payloads, error) { return msg.Payloads, nil @@ -243,15 +242,15 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { ) case *internal.UpdateCompleted: - wp.log.Debug("complete update request", zap.String("update id", command.ID)) + wp.log.Debug("complete update request", "update id", command.ID) if command.ID == "" { - wp.log.Error("update id is empty, can't complete update", zap.String("workflow id", wp.env.WorkflowInfo().WorkflowExecution.ID), zap.String("run id", wp.env.WorkflowInfo().WorkflowExecution.RunID)) + wp.log.Error("update id is empty, can't complete update", "workflow id", wp.env.WorkflowInfo().WorkflowExecution.ID, "run id", wp.env.WorkflowInfo().WorkflowExecution.RunID) return errors.Str("update id is empty, can't complete update") } if _, ok := wp.updateCompleteCb[command.ID]; !ok { - wp.log.Warn("no such update ID, can't complete update", zap.String("requested id", command.ID)) + wp.log.Warn("no such update ID, can't complete update", "requested id", command.ID) // TODO(rustatian): error here? return nil } @@ -260,15 +259,15 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { delete(wp.updateCompleteCb, command.ID) case *internal.UpdateValidated: - wp.log.Debug("validate update request", zap.String("update id", command.ID)) + wp.log.Debug("validate update request", "update id", command.ID) if command.ID == "" { - wp.log.Error("update id is empty, can't validate update", zap.String("workflow id", wp.env.WorkflowInfo().WorkflowExecution.ID), zap.String("run id", wp.env.WorkflowInfo().WorkflowExecution.RunID)) + wp.log.Error("update id is empty, can't validate update", "workflow id", wp.env.WorkflowInfo().WorkflowExecution.ID, "run id", wp.env.WorkflowInfo().WorkflowExecution.RunID) return errors.Str("update id is empty, can't validate update") } if _, ok := wp.updateValidateCb[command.ID]; !ok { - wp.log.Warn("no such update ID, can't validate update", zap.String("requested id", command.ID)) + wp.log.Warn("no such update ID, can't validate update", "requested id", command.ID) // TODO(rustatian): error here? return nil } @@ -281,7 +280,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } case *internal.CompleteWorkflow: - wp.log.Debug("complete workflow request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("complete workflow request", "ID", msg.ID) result, _ := wp.env.GetDataConverter().ToPayloads(completed) wp.mq.PushResponse(msg.ID, result, wp.getWorkflowWorkerPid()) @@ -293,7 +292,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { wp.env.Complete(nil, temporal.GetDefaultFailureConverter().FailureToError(msg.Failure)) case *internal.ContinueAsNew: - wp.log.Debug("continue-as-new request", zap.Uint64("ID", msg.ID), zap.String("name", command.Name)) + wp.log.Debug("continue-as-new request", "ID", msg.ID, "name", command.Name) result, _ := wp.env.GetDataConverter().ToPayloads(completed) wp.mq.PushResponse(msg.ID, result, wp.getWorkflowWorkerPid()) @@ -309,14 +308,14 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { }) case *internal.UpsertWorkflowSearchAttributes: - wp.log.Debug("upsert search attributes request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("upsert search attributes request", "ID", msg.ID) err := wp.env.UpsertSearchAttributes(command.SearchAttributes) if err != nil { return errors.E(op, err) } case *internal.UpsertWorkflowTypedSearchAttributes: - wp.log.Debug("upsert typed search attributes request", zap.Uint64("ID", msg.ID), zap.Any("search_attributes", command.SearchAttributes)) + wp.log.Debug("upsert typed search attributes request", "ID", msg.ID, "search_attributes", command.SearchAttributes) var sau []temporal.SearchAttributeUpdate for k, v := range command.SearchAttributes { @@ -327,14 +326,14 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { continue } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } if tt, ok := v.Value.(bool); ok { sau = append(sau, temporal.NewSearchAttributeKeyBool(k).ValueSet(tt)) } else { - wp.log.Warn("field value is not a bool type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not a bool type", "key", k, "value", v.Value) } case internal.FloatType: @@ -344,14 +343,14 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } if tt, ok := v.Value.(float64); ok { sau = append(sau, temporal.NewSearchAttributeKeyFloat64(k).ValueSet(tt)) } else { - wp.log.Warn("field value is not a float64 type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not a float64 type", "key", k, "value", v.Value) } case internal.IntType: @@ -361,7 +360,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } @@ -381,12 +380,12 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { case string: i, err := strconv.ParseInt(ti, 10, 64) if err != nil { - wp.log.Warn("failed to parse int", zap.Error(err)) + wp.log.Warn("failed to parse int", "error", err) continue } sau = append(sau, temporal.NewSearchAttributeKeyInt64(k).ValueSet(i)) default: - wp.log.Warn("field value is not an int type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not an int type", "key", k, "value", v.Value) } case internal.KeywordType: @@ -396,14 +395,14 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } if tt, ok := v.Value.(string); ok { sau = append(sau, temporal.NewSearchAttributeKeyKeyword(k).ValueSet(tt)) } else { - wp.log.Warn("field value is not a string type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not a string type", "key", k, "value", v.Value) } case internal.KeywordListType: if v.Operation == internal.TypedSearchAttributeOperationUnset { @@ -412,7 +411,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } @@ -428,7 +427,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } sau = append(sau, temporal.NewSearchAttributeKeyKeywordList(k).ValueSet(res)) default: - wp.log.Warn("field value is not a []string (strings array) type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not a []string (strings array) type", "key", k, "value", v.Value) } case internal.StringType: @@ -438,14 +437,14 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } if tt, ok := v.Value.(string); ok { sau = append(sau, temporal.NewSearchAttributeKeyString(k).ValueSet(tt)) } else { - wp.log.Warn("field value is not a string type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("field value is not a string type", "key", k, "value", v.Value) } case internal.DatetimeType: if v.Operation == internal.TypedSearchAttributeOperationUnset { @@ -454,7 +453,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } if v.Value == nil { - wp.log.Warn("field value is not set", zap.String("key", k)) + wp.log.Warn("field value is not set", "key", k) continue } @@ -466,7 +465,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { sau = append(sau, temporal.NewSearchAttributeKeyTime(k).ValueSet(tm)) } else { - wp.log.Warn("bool field value is not a bool type", zap.String("key", k), zap.Any("value", v.Value)) + wp.log.Warn("bool field value is not a bool type", "key", k, "value", v.Value) } } } @@ -482,7 +481,7 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } case *internal.SignalExternalWorkflow: - wp.log.Debug("signal external workflow request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("signal external workflow request", "ID", msg.ID) wp.env.SignalExternalWorkflow( command.Namespace, command.WorkflowID, @@ -496,11 +495,11 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { ) case *internal.CancelExternalWorkflow: - wp.log.Debug("cancel external workflow request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("cancel external workflow request", "ID", msg.ID) wp.env.RequestCancelExternalWorkflow(command.Namespace, command.WorkflowID, command.RunID, wp.createCallback(msg.ID, "CancelExternalWorkflow")) case *internal.Cancel: - wp.log.Debug("cancel request", zap.Uint64("ID", msg.ID)) + wp.log.Debug("cancel request", "ID", msg.ID) err := wp.canceller.Cancel(command.CommandIDs...) if err != nil { return errors.E(op, err) @@ -515,12 +514,12 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { } case *internal.Panic: - wp.log.Debug("panic", zap.String("failure", msg.Failure.String())) + wp.log.Debug("panic", "failure", msg.Failure.String()) // do not wrap error to pass it directly to Temporal return temporal.GetDefaultFailureConverter().FailureToError(msg.Failure) case *internal.UpsertMemo: - wp.log.Debug("upsert memo request", zap.Uint64("ID", msg.ID), zap.Any("memos", command.Memo)) + wp.log.Debug("upsert memo request", "ID", msg.ID, "memos", command.Memo) if len(command.Memo) == 0 { return nil } @@ -539,29 +538,29 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error { func (wp *Workflow) createLocalActivityCallback(id uint64) bindings.LocalActivityResultHandler { callback := func(lar *bindings.LocalActivityResultWrapper) { - wp.log.Debug("executing local activity callback", zap.Uint64("ID", id)) + wp.log.Debug("executing local activity callback", "ID", id) wp.canceller.Discard(id) if lar.Err != nil { - wp.log.Debug("error", zap.Error(lar.Err), zap.Int32("attempt", lar.Attempt), zap.Duration("backoff", lar.Backoff)) + wp.log.Debug("error", "error", lar.Err, "attempt", lar.Attempt, "backoff", lar.Backoff) wp.mq.PushError(id, temporal.GetDefaultFailureConverter().ErrorToFailure(lar.Err), wp.getWorkflowWorkerPid()) return } - wp.log.Debug("pushing local activity response", zap.Uint64("ID", id)) + wp.log.Debug("pushing local activity response", "ID", id) wp.mq.PushResponse(id, lar.Result, wp.getWorkflowWorkerPid()) } return func(lar *bindings.LocalActivityResultWrapper) { // timer cancel callback can happen inside the loop if atomic.LoadUint32(&wp.inLoop) == 1 { - wp.log.Debug("calling local activity callback IN LOOP", zap.Uint64("ID", id)) + wp.log.Debug("calling local activity callback IN LOOP", "ID", id) callback(lar) return } wp.callbacks = append(wp.callbacks, func() error { - wp.log.Debug("appending local activity callback", zap.Uint64("ID", id)) + wp.log.Debug("appending local activity callback", "ID", id) callback(lar) return nil }) @@ -570,16 +569,16 @@ func (wp *Workflow) createLocalActivityCallback(id uint64) bindings.LocalActivit func (wp *Workflow) createCallback(id uint64, t string) bindings.ResultHandler { callback := func(result *commonpb.Payloads, err error) { - wp.log.Debug("executing callback", zap.Uint64("ID", id), zap.String("type", t)) + wp.log.Debug("executing callback", "ID", id, "type", t) wp.canceller.Discard(id) if err != nil { - wp.log.Debug("error", zap.Error(err), zap.String("type", t)) + wp.log.Debug("error", "error", err, "type", t) wp.mq.PushError(id, temporal.GetDefaultFailureConverter().ErrorToFailure(err), wp.getWorkflowWorkerPid()) return } - wp.log.Debug("pushing response", zap.Uint64("ID", id), zap.String("type", t)) + wp.log.Debug("pushing response", "ID", id, "type", t) // fetch original payload wp.mq.PushResponse(id, result, wp.getWorkflowWorkerPid()) } @@ -587,13 +586,13 @@ func (wp *Workflow) createCallback(id uint64, t string) bindings.ResultHandler { return func(result *commonpb.Payloads, err error) { // timer cancel callback can happen inside the loop if atomic.LoadUint32(&wp.inLoop) == 1 { - wp.log.Debug("calling callback IN LOOP", zap.Uint64("ID", id), zap.String("type", t)) + wp.log.Debug("calling callback IN LOOP", "ID", id, "type", t) callback(result, err) return } wp.callbacks = append(wp.callbacks, func() error { - wp.log.Debug("appending callback", zap.Uint64("ID", id), zap.String("type", t)) + wp.log.Debug("appending callback", "ID", id, "type", t) callback(result, err) return nil }) @@ -603,7 +602,7 @@ func (wp *Workflow) createCallback(id uint64, t string) bindings.ResultHandler { // callback to be called inside the queue processing, adds new messages at the end of the queue func (wp *Workflow) createContinuableCallback(id uint64, t string) bindings.ResultHandler { callback := func(result *commonpb.Payloads, err error) { - wp.log.Debug("executing continuable callback", zap.Uint64("ID", id), zap.String("type", t)) + wp.log.Debug("executing continuable callback", "ID", id, "type", t) wp.canceller.Discard(id) if err != nil { @@ -744,7 +743,7 @@ func (wp *Workflow) getWorkflowWorkerPid() int { wp.log.Debug("fetching workflow worker pid") wfw := wp.pool.Workers() if len(wfw) > 0 { - wp.log.Debug("workflow worker pid found", zap.Int("pid", int(wfw[0].Pid()))) + wp.log.Debug("workflow worker pid found", "pid", int(wfw[0].Pid())) return int(wfw[0].Pid()) } wp.log.Debug("workflow worker pid not found") diff --git a/aggregatedpool/interceptor.go b/aggregatedpool/interceptor.go index 4da55d3c..59e3e355 100644 --- a/aggregatedpool/interceptor.go +++ b/aggregatedpool/interceptor.go @@ -3,7 +3,7 @@ package aggregatedpool import ( "context" - "github.com/temporalio/roadrunner-temporal/v5/api" + "github.com/temporalio/roadrunner-temporal/v6/api" "go.temporal.io/sdk/interceptor" ) diff --git a/aggregatedpool/local_activity.go b/aggregatedpool/local_activity.go index ebd3fe1c..f43fbc2d 100644 --- a/aggregatedpool/local_activity.go +++ b/aggregatedpool/local_activity.go @@ -5,26 +5,27 @@ import ( "sync" "sync/atomic" + "log/slog" + "github.com/google/uuid" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/goridge/v3/pkg/frame" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/goridge/v4/pkg/frame" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" commonpb "go.temporal.io/api/common/v1" tActivity "go.temporal.io/sdk/activity" "go.temporal.io/sdk/temporal" - "go.uber.org/zap" ) type LocalActivityFn struct { codec api.Codec pool api.Pool - log *zap.Logger + log *slog.Logger seqID uint64 } -func NewLocalActivityFn(codec api.Codec, pool api.Pool, log *zap.Logger) *LocalActivityFn { +func NewLocalActivityFn(codec api.Codec, pool api.Pool, log *slog.Logger) *LocalActivityFn { return &LocalActivityFn{ codec: codec, pool: pool, @@ -54,7 +55,7 @@ func (la *LocalActivityFn) ExecuteLA(ctx context.Context, hdr *commonpb.Header, Header: hdr, } - la.log.Debug("executing local activity fn", zap.Uint64("ID", msg.ID), zap.String("task-queue", info.TaskQueue), zap.String("la ID", info.ActivityID)) + la.log.Debug("executing local activity fn", "ID", msg.ID, "task-queue", info.TaskQueue, "la ID", info.ActivityID) pl := getPld() defer putPld(pl) diff --git a/aggregatedpool/workers.go b/aggregatedpool/workers.go index 7ff15525..20fc1326 100644 --- a/aggregatedpool/workers.go +++ b/aggregatedpool/workers.go @@ -4,10 +4,12 @@ import ( "fmt" "strings" + "log/slog" + "github.com/google/uuid" "github.com/roadrunner-server/errors" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" tActivity "go.temporal.io/sdk/activity" temporalClient "go.temporal.io/sdk/client" "go.temporal.io/sdk/contrib/sysinfo" @@ -15,7 +17,6 @@ import ( sdkinterceptor "go.temporal.io/sdk/interceptor" "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" - "go.uber.org/zap" ) const tq = "taskqueue" @@ -117,7 +118,7 @@ func registerWorkflow(register func(), name, taskQueue string) (err error) { return nil } -func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo, log *zap.Logger, tc temporalClient.Client, interceptors map[string]api.Interceptor, configuredInterceptors []string) ([]worker.Worker, error) { +func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo, log *slog.Logger, tc temporalClient.Client, interceptors map[string]api.Interceptor, configuredInterceptors []string) ([]worker.Worker, error) { resolved, err := ResolveInterceptors(interceptors, configuredInterceptors) if err != nil { return nil, err @@ -127,7 +128,7 @@ func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo for i := range wi { workerInfo := wi[i] - log.Debug("worker info", zap.Any("worker_info", workerInfo)) + log.Debug("worker info", "worker_info", workerInfo) // Override to 0: RoadRunner manages worker lifecycle independently workerInfo.Options.WorkerStopTimeout = 0 @@ -174,7 +175,7 @@ func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo } dynamicWorkflowRegistered = true - log.Debug("dynamic workflow registered", zap.String(tq, workerInfo.TaskQueue), zap.Any("workflow name", wf.Name)) + log.Debug("dynamic workflow registered", tq, workerInfo.TaskQueue, "workflow name", wf.Name) continue } @@ -190,11 +191,11 @@ func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo return nil, err } - log.Debug("workflow registered", zap.String(tq, workerInfo.TaskQueue), zap.Any("workflow name", wf.Name), zap.Int("versioning_behavior", int(wf.VersioningBehavior))) + log.Debug("workflow registered", tq, workerInfo.TaskQueue, "workflow name", wf.Name, "versioning_behavior", int(wf.VersioningBehavior)) } if actDef.disableActivityWorkers { - log.Debug("activity workers disabled", zap.String(tq, workerInfo.TaskQueue)) + log.Debug("activity workers disabled", tq, workerInfo.TaskQueue) // add worker to the pool without activities workers = append(workers, wrk) continue @@ -207,13 +208,13 @@ func TemporalWorkers(wDef *Workflow, actDef *Activity, wi []*internal.WorkerInfo SkipInvalidStructFunctions: false, }) - log.Debug("activity registered", zap.String(tq, workerInfo.TaskQueue), zap.Any("workflow name", activity.Name)) + log.Debug("activity registered", tq, workerInfo.TaskQueue, "workflow name", activity.Name) } // add worker to the pool workers = append(workers, wrk) } - log.Debug("workers initialized", zap.Int("num_workers", len(workers))) + log.Debug("workers initialized", "num_workers", len(workers)) return workers, nil } diff --git a/aggregatedpool/workers_test.go b/aggregatedpool/workers_test.go index b46d45a7..3703b503 100644 --- a/aggregatedpool/workers_test.go +++ b/aggregatedpool/workers_test.go @@ -3,15 +3,16 @@ package aggregatedpool import ( "testing" + "log/slog" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" commonpb "go.temporal.io/api/common/v1" "go.temporal.io/sdk/client" "go.temporal.io/sdk/converter" sdkinterceptor "go.temporal.io/sdk/interceptor" - "go.uber.org/zap" ) // mockPayloadConverter implements converter.PayloadConverter for testing. @@ -294,7 +295,7 @@ func TestTemporalWorkers_MultipleDynamicWorkflows_ReturnsError(t *testing.T) { }, }} - _, err = TemporalWorkers(nil, nil, workers, zap.NewNop(), temporalClient, nil, nil) + _, err = TemporalWorkers(nil, nil, workers, slog.New(slog.DiscardHandler), temporalClient, nil, nil) require.Error(t, err) assert.Contains(t, err.Error(), "multiple dynamic workflows") assert.Contains(t, err.Error(), "default") diff --git a/aggregatedpool/workflow.go b/aggregatedpool/workflow.go index 3d43d8bd..6d3cd250 100644 --- a/aggregatedpool/workflow.go +++ b/aggregatedpool/workflow.go @@ -8,18 +8,19 @@ import ( "sync/atomic" "time" + "log/slog" + "github.com/google/uuid" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/canceller" - "github.com/temporalio/roadrunner-temporal/v5/internal" - "github.com/temporalio/roadrunner-temporal/v5/queue" - "github.com/temporalio/roadrunner-temporal/v5/registry" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/canceller" + "github.com/temporalio/roadrunner-temporal/v6/internal" + "github.com/temporalio/roadrunner-temporal/v6/queue" + "github.com/temporalio/roadrunner-temporal/v6/registry" commonpb "go.temporal.io/api/common/v1" enumspb "go.temporal.io/api/enums/v1" temporalClient "go.temporal.io/sdk/client" bindings "go.temporal.io/sdk/internalbindings" - "go.uber.org/zap" ) // implements WorkflowDefinition interface @@ -67,7 +68,7 @@ type Workflow struct { updateCompleteCb map[string]func(res *internal.Message) updateValidateCb map[string]func(res *internal.Message) - log *zap.Logger + log *slog.Logger mh temporalClient.MetricsHandler // objects pool @@ -75,7 +76,7 @@ type Workflow struct { } // NewWorkflowDefinition ... WorkflowDefinition Constructor -func NewWorkflowDefinition(codec api.Codec, la LaFn, pool api.Pool, log *zap.Logger) *Workflow { +func NewWorkflowDefinition(codec api.Codec, la LaFn, pool api.Pool, log *slog.Logger) *Workflow { return &Workflow{ rrID: uuid.NewString(), log: log, @@ -116,7 +117,7 @@ func (wp *Workflow) NewWorkflowDefinition() bindings.WorkflowDefinition { // Execute implementation must be asynchronous. func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.Header, input *commonpb.Payloads) { - wp.log.Debug("workflow execute", zap.String("runID", env.WorkflowInfo().WorkflowExecution.RunID), zap.Any("workflow info", env.WorkflowInfo())) + wp.log.Debug("workflow execute", "runID", env.WorkflowInfo().WorkflowExecution.RunID, "workflow info", env.WorkflowInfo()) wp.mh = env.GetMetricsHandler() wp.env = env @@ -164,7 +165,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case enumspb.INDEXED_VALUE_TYPE_TEXT: str, ok := v.(string) if !ok { - wp.log.Warn("typed search attribute found, but it is not a string", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a string", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -174,7 +175,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case enumspb.INDEXED_VALUE_TYPE_KEYWORD: str, ok := v.(string) if !ok { - wp.log.Warn("typed search attribute found, but it is not a string[keyword]", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a string[keyword]", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -196,7 +197,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case string: res, err := strconv.Atoi(tt) if err != nil { - wp.log.Warn("typed search attribute found, but it is not an int", zap.Error(err), zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not an int", "error", err, "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -204,13 +205,13 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H Value: res, } default: - wp.log.Warn("typed search attribute found, but it is not an int", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not an int", "key", k.GetName()) continue } case enumspb.INDEXED_VALUE_TYPE_DOUBLE: str, ok := v.(float64) if !ok { - wp.log.Warn("typed search attribute found, but it is not a float64", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a float64", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -220,7 +221,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case enumspb.INDEXED_VALUE_TYPE_BOOL: str, ok := v.(bool) if !ok { - wp.log.Warn("typed search attribute found, but it is not a bool", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a bool", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -230,7 +231,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case enumspb.INDEXED_VALUE_TYPE_DATETIME: str, ok := v.(time.Time) if !ok { - wp.log.Warn("typed search attribute found, but it is not a datetime", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a datetime", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -240,7 +241,7 @@ func (wp *Workflow) Execute(env bindings.WorkflowEnvironment, header *commonpb.H case enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST: str, ok := v.([]string) if !ok { - wp.log.Warn("typed search attribute found, but it is not a []string", zap.String("key", k.GetName())) + wp.log.Warn("typed search attribute found, but it is not a []string", "key", k.GetName()) continue } tsaParsed[k.GetName()] = &internal.TypedSearchAttribute{ @@ -284,7 +285,7 @@ func (wp *Workflow) OnWorkflowTaskStarted(t time.Duration) { atomic.StoreUint32(&wp.inLoop, 0) }() - wp.log.Debug("workflow task started", zap.Duration("time", t)) + wp.log.Debug("workflow task started", "time", t) var err error // do not copy @@ -361,7 +362,7 @@ func (wp *Workflow) StackTrace() string { } func (wp *Workflow) Close() { - wp.log.Debug("close workflow", zap.String("RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID)) + wp.log.Debug("close workflow", "RunID", wp.env.WorkflowInfo().WorkflowExecution.RunID) // when closing the workflow, we should drain(execute) unhandled updates if wp.env.DrainUnhandledUpdates() { wp.log.Info("drained unhandled updates") diff --git a/api/interfaces.go b/api/interfaces.go index 7abb0e19..2a3ed3ad 100644 --- a/api/interfaces.go +++ b/api/interfaces.go @@ -2,17 +2,17 @@ package api import ( "context" + "log/slog" "time" - "github.com/roadrunner-server/pool/payload" - "github.com/roadrunner-server/pool/pool" - "github.com/roadrunner-server/pool/state/process" - "github.com/roadrunner-server/pool/worker" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/roadrunner-server/pool/v2/pool" + "github.com/roadrunner-server/pool/v2/state/process" + "github.com/roadrunner-server/pool/v2/worker" + "github.com/temporalio/roadrunner-temporal/v6/internal" "go.temporal.io/sdk/interceptor" - "go.uber.org/zap" - staticPool "github.com/roadrunner-server/pool/pool/static_pool" + staticPool "github.com/roadrunner-server/pool/v2/pool/static_pool" ) type Interceptor interface { @@ -64,6 +64,6 @@ type Configurer interface { // Server creates workers for the application. type Server interface { - NewPool(ctx context.Context, cfg *pool.Config, env map[string]string, _ *zap.Logger) (*staticPool.Pool, error) - NewPoolWithOptions(ctx context.Context, cfg *pool.Config, env map[string]string, _ *zap.Logger, options ...staticPool.Options) (*staticPool.Pool, error) + NewPool(ctx context.Context, cfg *pool.Config, env map[string]string, _ *slog.Logger) (*staticPool.Pool, error) + NewPoolWithOptions(ctx context.Context, cfg *pool.Config, env map[string]string, _ *slog.Logger, options ...staticPool.Options) (*staticPool.Pool, error) } diff --git a/config.go b/config.go index 47720a0a..acebffe5 100644 --- a/config.go +++ b/config.go @@ -6,7 +6,7 @@ import ( "time" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/pool/pool" + "github.com/roadrunner-server/pool/v2/pool" ) // Config of the temporal client and dependent services. diff --git a/go.mod b/go.mod index ff5b5714..68ea74dc 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/temporalio/roadrunner-temporal/v5 +module github.com/temporalio/roadrunner-temporal/v6 go 1.26.5 @@ -6,11 +6,12 @@ require ( github.com/goccy/go-json v0.10.6 github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect - github.com/roadrunner-server/api/v4 v4.24.0 + github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14 + github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2 github.com/roadrunner-server/endure/v2 v2.6.2 github.com/roadrunner-server/errors v1.5.0 github.com/roadrunner-server/events v1.0.1 - github.com/roadrunner-server/pool v1.1.3 + github.com/roadrunner-server/pool/v2 v2.0.0-beta.1 github.com/stretchr/testify v1.12.1 github.com/uber-go/tally/v4 v4.1.17 go.temporal.io/api v1.63.5 @@ -18,7 +19,6 @@ require ( go.temporal.io/sdk/contrib/sysinfo v0.1.1 go.temporal.io/sdk/contrib/tally v0.2.0 go.temporal.io/server v1.31.2 - go.uber.org/zap v1.28.0 google.golang.org/protobuf v1.36.12 ) @@ -48,7 +48,7 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.70.1 // indirect github.com/prometheus/procfs v0.21.1 // indirect - github.com/roadrunner-server/goridge/v3 v3.8.3 + github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3 github.com/robfig/cron v1.2.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect // gopsutil v4.25+ is required: it adds cgo-free darwin CPU sampling, which SysInfoProvider @@ -62,7 +62,6 @@ require ( github.com/twmb/murmur3 v1.1.8 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.uber.org/atomic v1.11.0 // indirect - go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.57.0 // indirect golang.org/x/sync v0.22.0 // indirect golang.org/x/sys v0.47.0 // indirect @@ -77,8 +76,3 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect ) - -require ( - go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect -) diff --git a/go.sum b/go.sum index da87fe3e..91eb7c24 100644 --- a/go.sum +++ b/go.sum @@ -135,7 +135,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -163,7 +162,6 @@ github.com/nexus-rpc/nexus-proto-annotations v0.1.0 h1:2fELd+9sqUtNu6Fg//pw8YFsx github.com/nexus-rpc/nexus-proto-annotations v0.1.0/go.mod h1:n3UjF1bPCW8llR8tHvbxJ+27yPWrhpo8w/Yg1IOuY0Y= github.com/nexus-rpc/sdk-go v0.7.0 h1:38NrfY5rLnZAiMMs2ZfCKI/CSDzdfJG+27iAgfA8bUI= github.com/nexus-rpc/sdk-go v0.7.0/go.mod h1:FHdPfVQwRuJFZFTF0Y2GOAxCrbIBNrcPna9slkGKPYk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/opencontainers/runtime-spec v1.3.0 h1:YZupQUdctfhpZy3TM39nN9Ika5CBWT5diQ8ibYCRkxg= github.com/opencontainers/runtime-spec v1.3.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -199,18 +197,20 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= -github.com/roadrunner-server/api/v4 v4.24.0 h1:99lN8nu7aD76d1fru4+MZkf9m8+YJ22Jy+qVoDwn4OY= -github.com/roadrunner-server/api/v4 v4.24.0/go.mod h1:O0LputszJr6NXMw0SKyWaiS/C9K6JVh9HV2BHKXeosA= +github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14 h1:sTskv/3ImOZlUdtHuj9uT24gm1gQl/qU8rFNvn3MzhU= +github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14/go.mod h1:Y4rsabWjr4Y10Jg6H8J5NDitQqlnXmGhCdgR+zyLYkI= +github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2 h1:GqsZzWQ5jMXRF1O/b8IqFz9PLpS7Ui0K4OyACLql2MI= +github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2/go.mod h1:2v4yUK5Kvbvq8C3IkDoBkuamq9h+7i/JLjyf7k1j5JM= github.com/roadrunner-server/endure/v2 v2.6.2 h1:sIB4kTyE7gtT3fDhuYWUYn6Vt/dcPtiA6FoNS1eS+84= github.com/roadrunner-server/endure/v2 v2.6.2/go.mod h1:t/2+xpNYgGBwhzn83y2MDhvhZ19UVq1REcvqn7j7RB8= github.com/roadrunner-server/errors v1.5.0 h1:unG7LKIZrSzkCCF3YLRLA5VyqE0KKomofXVJUXJe00g= github.com/roadrunner-server/errors v1.5.0/go.mod h1:g9fo/T2C13cWRDR9PW1r0ZAOSQfNhWAZawyfkGiaHuI= github.com/roadrunner-server/events v1.0.1 h1:waCkKhxhzdK3VcI1xG22l+h+0J+Nfdpxjhyy01Un+kI= github.com/roadrunner-server/events v1.0.1/go.mod h1:WZRqoEVaFm209t52EuoT7ISUtvX6BrCi6bI/7pjkVC0= -github.com/roadrunner-server/goridge/v3 v3.8.3 h1:XmjrOFnI6ZbQTPaP39DEk8KwLUNTgjluK3pcZaW6ixQ= -github.com/roadrunner-server/goridge/v3 v3.8.3/go.mod h1:4TZU8zgkKIZCsH51qwGMpvyXCT59u/8z6q8sCe4ZGAQ= -github.com/roadrunner-server/pool v1.1.3 h1:KMsiL6yuYBWGk73bdO0akwP+fJ63bxDF972JukCGsxI= -github.com/roadrunner-server/pool v1.1.3/go.mod h1:8ceC7NvZKJRciv+KJmcyk5CeDugoel6GD+crm5kBFW0= +github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3 h1:+kUw00/fpqwdMWrPMYW+OZH3O4gEar8hqrY7I+nAztA= +github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3/go.mod h1:1aHppV68y/VqRED/AsfNg59sft9aQOhqgr5Z5n49jbM= +github.com/roadrunner-server/pool/v2 v2.0.0-beta.1 h1:jpYXFtdD6QGAdAGPgMxrNi3j1CegCRpb2y+A+3GnXFA= +github.com/roadrunner-server/pool/v2 v2.0.0-beta.1/go.mod h1:Bo1wT7RtL3eyQHXBUohNhtj/yAmRt6Rq8smuBg5pWkY= github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -290,11 +290,7 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= -go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= @@ -441,8 +437,6 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/validator.v2 v2.0.0-20200605151824-2b28d334fa05/go.mod h1:o4V0GXN9/CAmCsvJ0oXYZvrZOe7syiDZSN1GWGZTGzc= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/go.work.sum b/go.work.sum index 4ca4a306..32850fee 100644 --- a/go.work.sum +++ b/go.work.sum @@ -977,6 +977,7 @@ github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b h1:WR1qVJzbvrVywhAk4kMQKRPx09AZVI0NdEdYs59iHcA= github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b/go.mod h1:v9FBN7gdVTpiD/+LZ7Po0UKvROyT87uLVxTHVky/dlQ= github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-farm v0.0.0-20140601200337-fc41e106ee0e/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -1489,6 +1490,7 @@ github.com/pkg/sftp v1.13.7 h1:uv+I3nNJvlKZIQGSr8JVQLNHFU9YhhNpvC14Y6KgmSM= github.com/pkg/sftp v1.13.7/go.mod h1:KMKI0t3T6hfA+lTR/ssZdunHo+uwq7ghoN09/FSu3DY= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prashantv/protectmem v0.0.0-20171002184600-e20412882b3a h1:AA9vgIBDjMHPC2McaGPojgV2dcI78ZC0TLNhYCXEKH8= github.com/prashantv/protectmem v0.0.0-20171002184600-e20412882b3a/go.mod h1:lzZQ3Noex5pfAy7mkAeCjcBDteYU85uWWnJ/y6gKU8k= @@ -2669,6 +2671,7 @@ google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXn google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= diff --git a/info.go b/info.go index e4d5592c..5623cb4e 100644 --- a/info.go +++ b/info.go @@ -5,10 +5,10 @@ import ( "time" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/goridge/v3/pkg/frame" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/goridge/v4/pkg/frame" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" ) func WorkerInfo(c api.Codec, p api.Pool, rrVersion string, wwPID int) ([]*internal.WorkerInfo, error) { diff --git a/internal.go b/internal.go index bae5d446..0c0bf8c8 100644 --- a/internal.go +++ b/internal.go @@ -7,19 +7,18 @@ import ( "time" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/pool/pool" - "github.com/temporalio/roadrunner-temporal/v5/aggregatedpool" - "github.com/temporalio/roadrunner-temporal/v5/dataconverter" - "github.com/temporalio/roadrunner-temporal/v5/internal/codec/proto" - "github.com/temporalio/roadrunner-temporal/v5/internal/logger" + "github.com/roadrunner-server/pool/v2/pool" + "github.com/temporalio/roadrunner-temporal/v6/aggregatedpool" + "github.com/temporalio/roadrunner-temporal/v6/dataconverter" + "github.com/temporalio/roadrunner-temporal/v6/internal/codec/proto" + "github.com/temporalio/roadrunner-temporal/v6/internal/logger" tclient "go.temporal.io/sdk/client" "go.temporal.io/sdk/converter" "go.temporal.io/sdk/worker" - "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/metadata" - staticPool "github.com/roadrunner-server/pool/pool/static_pool" + staticPool "github.com/roadrunner-server/pool/v2/pool/static_pool" ) const ( @@ -170,10 +169,10 @@ func (p *Plugin) initTemporalClient(phpSdkVersion string, flags map[string]strin heartbeatInterval := p.config.WorkerHeartbeatInterval switch { case heartbeatInterval > 0 && heartbeatInterval < time.Second: - p.log.Warn("worker_heartbeat_interval below 1s, using 1s", zap.Duration("configured", heartbeatInterval)) + p.log.Warn("worker_heartbeat_interval below 1s, using 1s", "configured", heartbeatInterval) heartbeatInterval = time.Second case heartbeatInterval > 60*time.Second: - p.log.Warn("worker_heartbeat_interval above 60s, using 60s", zap.Duration("configured", heartbeatInterval)) + p.log.Warn("worker_heartbeat_interval above 60s, using 60s", "configured", heartbeatInterval) heartbeatInterval = 60 * time.Second } @@ -187,7 +186,7 @@ func (p *Plugin) initTemporalClient(phpSdkVersion string, flags map[string]strin HostPort: p.config.Address, MetricsHandler: p.temporal.mh, Namespace: p.config.Namespace, - Logger: logger.NewZapAdapter(p.log), + Logger: logger.NewSlogAdapter(p.log), DataConverter: dc, WorkerHeartbeatInterval: heartbeatInterval, SdkName: clientNameHeaderValue, @@ -214,7 +213,7 @@ func (p *Plugin) initTemporalClient(phpSdkVersion string, flags map[string]strin return connectError(p.config.Address, err) } - p.log.Info("connected to temporal server", zap.String("address", p.config.Address)) + p.log.Info("connected to temporal server", "address", p.config.Address) return nil } diff --git a/internal/codec/proto/proto.go b/internal/codec/proto/proto.go index d3e4a7e9..e7f9579d 100644 --- a/internal/codec/proto/proto.go +++ b/internal/codec/proto/proto.go @@ -1,27 +1,28 @@ package proto import ( + "context" + "log/slog" "sync" "github.com/goccy/go-json" - protocolV1 "github.com/roadrunner-server/api/v4/build/temporal/v1" + protocolV1 "github.com/roadrunner-server/api-go/v6/temporal/v1" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/pool/payload" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/roadrunner-server/pool/v2/payload" + "github.com/temporalio/roadrunner-temporal/v6/internal" "go.temporal.io/sdk/converter" - "go.uber.org/zap" "google.golang.org/protobuf/proto" ) // Codec uses protobuf to exchange messages with underlying workers. type Codec struct { - log *zap.Logger + log *slog.Logger dc converter.DataConverter frPool sync.Pool } // NewCodec creates new Proto communication Codec. -func NewCodec(log *zap.Logger, dc converter.DataConverter) *Codec { +func NewCodec(log *slog.Logger, dc converter.DataConverter) *Codec { return &Codec{ log: log, dc: dc, @@ -52,7 +53,10 @@ func (c *Codec) Encode(ctx *internal.Context, p *payload.Payload, msg ...*intern } request.Messages[i] = pm - c.log.Debug("outgoing message", zap.Uint64("id", pm.Id), zap.ByteString("data", p.Body), zap.ByteString("context", p.Context)) + // string conversions copy the payload, skip them unless debug logging is on + if c.log.Enabled(context.Background(), slog.LevelDebug) { + c.log.Debug("outgoing message", "id", pm.Id, "data", string(p.Body), "context", string(p.Context)) + } } // context is always in JSON format @@ -94,7 +98,10 @@ func (c *Codec) Decode(pld *payload.Payload, result *[]*internal.Message) error return errM } - c.log.Debug("received message", zap.Any("command", msg.Command), zap.Uint64("id", msg.ID), zap.ByteString("data", pld.Body)) + // string conversion copies the payload, skip it unless debug logging is on + if c.log.Enabled(context.Background(), slog.LevelDebug) { + c.log.Debug("received message", "command", msg.Command, "id", msg.ID, "data", string(pld.Body)) + } *result = append(*result, msg) } @@ -115,7 +122,7 @@ func (c *Codec) DecodeWorkerInfo(p *payload.Payload, wi *[]*internal.WorkerInfo) } if len(info) != 1 { - c.log.Error("received not valid workflow info", zap.Any("data", info)) + c.log.Error("received not valid workflow info", "data", info) return errors.E(op, errors.Str("unable to read worker info")) } diff --git a/internal/logger/doc.go b/internal/logger/doc.go index a3a2d015..111118bd 100644 --- a/internal/logger/doc.go +++ b/internal/logger/doc.go @@ -1,3 +1,3 @@ -// Package logger provides an adapter that bridges zap.Logger with the +// Package logger provides an adapter that bridges slog.Logger with the // go.temporal.io/sdk/log.Logger interface used by the Temporal SDK client. package logger diff --git a/internal/logger/wrapper.go b/internal/logger/wrapper.go index 8e2ada47..55c6dfb9 100644 --- a/internal/logger/wrapper.go +++ b/internal/logger/wrapper.go @@ -1,55 +1,71 @@ package logger import ( + "context" "fmt" - - "go.uber.org/zap" + "log/slog" + "runtime" + "time" ) -type ZapAdapter struct { - zl *zap.Logger +// SlogAdapter bridges an slog.Logger to the Temporal SDK log.Logger interface. +type SlogAdapter struct { + log *slog.Logger } -// NewZapAdapter ... which uses general log interface -func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter { - return &ZapAdapter{ - zl: zapLogger.WithOptions(zap.AddCallerSkip(1)), +// NewSlogAdapter wraps the given slog.Logger into the Temporal SDK log interface. +func NewSlogAdapter(log *slog.Logger) *SlogAdapter { + return &SlogAdapter{ + log: log, } } -func (log *ZapAdapter) Debug(msg string, keyvals ...any) { - log.zl.Debug(msg, log.fields(keyvals)...) +func (l *SlogAdapter) Debug(msg string, keyvals ...any) { + l.emit(slog.LevelDebug, msg, keyvals) +} + +func (l *SlogAdapter) Info(msg string, keyvals ...any) { + l.emit(slog.LevelInfo, msg, keyvals) } -func (log *ZapAdapter) Info(msg string, keyvals ...any) { - log.zl.Info(msg, log.fields(keyvals)...) +func (l *SlogAdapter) Warn(msg string, keyvals ...any) { + l.emit(slog.LevelWarn, msg, keyvals) } -func (log *ZapAdapter) Warn(msg string, keyvals ...any) { - log.zl.Warn(msg, log.fields(keyvals)...) +func (l *SlogAdapter) Error(msg string, keyvals ...any) { + l.emit(slog.LevelError, msg, keyvals) } -func (log *ZapAdapter) Error(msg string, keyvals ...any) { - log.zl.Error(msg, log.fields(keyvals)...) +// emit builds the record manually so the source location points at the +// Temporal SDK call site instead of this adapter. +func (l *SlogAdapter) emit(level slog.Level, msg string, keyvals []any) { + ctx := context.Background() + if !l.log.Enabled(ctx, level) { + return + } + + var pcs [1]uintptr + // skip runtime.Callers, emit and the exported wrapper method + runtime.Callers(3, pcs[:]) + + r := slog.NewRecord(time.Now(), level, msg, pcs[0]) + r.Add(normalize(keyvals)...) + + _ = l.log.Handler().Handle(ctx, r) } -func (log *ZapAdapter) fields(keyvals []any) []zap.Field { - // we should have even number of keys and values +// normalize keeps key/value pairs aligned: slog consumes a single element for a +// non-string key, which would shift every pair after it. +func normalize(keyvals []any) []any { if len(keyvals)%2 != 0 { - return []zap.Field{zap.Error(fmt.Errorf("odd number of keyvals pairs: %v", keyvals))} + return []any{"error", fmt.Errorf("odd number of keyvals pairs: %v", keyvals)} } - zf := make([]zap.Field, len(keyvals)/2) - j := 0 for i := 0; i < len(keyvals); i += 2 { - key, ok := keyvals[i].(string) - if !ok { - key = fmt.Sprintf("%v", keyvals[i]) + if _, ok := keyvals[i].(string); !ok { + keyvals[i] = fmt.Sprintf("%v", keyvals[i]) } - - zf[j] = zap.Any(key, keyvals[i+1]) - j++ } - return zf + return keyvals } diff --git a/metrics.go b/metrics.go index c54c9347..4c6a240a 100644 --- a/metrics.go +++ b/metrics.go @@ -5,17 +5,18 @@ import ( "strconv" "time" + "log/slog" + "github.com/cactus/go-statsd-client/v5/statsd" prom "github.com/prometheus/client_golang/prometheus" "github.com/roadrunner-server/errors" - "github.com/roadrunner-server/pool/fsm" - "github.com/roadrunner-server/pool/state/process" + "github.com/roadrunner-server/pool/v2/fsm" + "github.com/roadrunner-server/pool/v2/state/process" "github.com/uber-go/tally/v4" "github.com/uber-go/tally/v4/prometheus" tclient "go.temporal.io/sdk/client" ttally "go.temporal.io/sdk/contrib/tally" // temporal tally hanlders statsdreporter "go.temporal.io/server/common/metrics/tally/statsd" - "go.uber.org/zap" ) const ( @@ -46,12 +47,12 @@ func newStatsExporter(stats Informer) *StatsExporter { } } -func newPrometheusScope(c prometheus.Configuration, prefix string, log *zap.Logger) (tally.Scope, io.Closer, error) { +func newPrometheusScope(c prometheus.Configuration, prefix string, log *slog.Logger) (tally.Scope, io.Closer, error) { reporter, err := c.NewReporter( prometheus.ConfigurationOptions{ Registry: prom.NewRegistry(), OnError: func(err error) { - log.Error("prometheus registry", zap.Error(err)) + log.Error("prometheus registry", "error", err) }, }, ) @@ -123,7 +124,7 @@ func newStatsdScope(statsdConfig *Statsd) (tally.Scope, io.Closer, error) { } // init RR metrics -func initMetrics(cfg *Config, log *zap.Logger) (tclient.MetricsHandler, io.Closer, error) { +func initMetrics(cfg *Config, log *slog.Logger) (tclient.MetricsHandler, io.Closer, error) { switch cfg.Metrics.Driver { case driverPrometheus: ms, cl, err := newPrometheusScope(prometheus.Configuration{ diff --git a/plugin.go b/plugin.go index 340b4061..e0e9f8ae 100644 --- a/plugin.go +++ b/plugin.go @@ -11,20 +11,21 @@ import ( "sync/atomic" "time" + "log/slog" + "github.com/roadrunner-server/endure/v2/dep" "github.com/roadrunner-server/errors" "github.com/roadrunner-server/events" - "github.com/roadrunner-server/pool/state/process" - "github.com/temporalio/roadrunner-temporal/v5/aggregatedpool" - "github.com/temporalio/roadrunner-temporal/v5/api" - "github.com/temporalio/roadrunner-temporal/v5/internal" - "github.com/temporalio/roadrunner-temporal/v5/internal/codec/proto" + "github.com/roadrunner-server/pool/v2/state/process" + "github.com/temporalio/roadrunner-temporal/v6/aggregatedpool" + "github.com/temporalio/roadrunner-temporal/v6/api" + "github.com/temporalio/roadrunner-temporal/v6/internal" + "github.com/temporalio/roadrunner-temporal/v6/internal/codec/proto" tclient "go.temporal.io/sdk/client" "go.temporal.io/sdk/converter" "go.temporal.io/sdk/worker" - "go.uber.org/zap" - "github.com/roadrunner-server/pool/pool/static_pool" + "github.com/roadrunner-server/pool/v2/pool/static_pool" ) const ( @@ -47,7 +48,7 @@ const ( ) type Logger interface { - NamedLogger(name string) *zap.Logger + NamedLogger(name string) *slog.Logger } // temporal structure contains temporal specific structures @@ -70,7 +71,7 @@ type Plugin struct { mu sync.RWMutex server api.Server - log *zap.Logger + log *slog.Logger config *Config statsExporter *StatsExporter codec *proto.Codec @@ -206,7 +207,7 @@ func (p *Plugin) Serve() chan error { switch strings.Contains(ev.Message(), strconv.Itoa(p.wwPID)) { // stopped workflow worker -> full reset case true: - p.log.Debug("workflow worker stopped, resetting", zap.String("message", ev.Message())) + p.log.Debug("workflow worker stopped, resetting", "message", ev.Message()) errR := p.Reset() if errR != nil { errCh <- errors.E(op, errors.Errorf("error during reset: %#v, event: %s", errR, ev.Message())) @@ -214,7 +215,7 @@ func (p *Plugin) Serve() chan error { } // stopped one of the activity workers -> already replaced by the pool, nothing to do case false: - p.log.Debug("activity worker stopped, replaced by the pool", zap.String("message", ev.Message())) + p.log.Debug("activity worker stopped, replaced by the pool", "message", ev.Message()) } case <-p.stopCh: @@ -238,6 +239,12 @@ func (p *Plugin) Stop(ctx context.Context) error { p.stopCh <- struct{}{} p.eventBus = nil + // stop receiving tasks: polling must stop before the pools are destroyed, + // otherwise a retiring worker can accept a queued task while the pools are draining + for i := 0; i < len(p.temporal.workers); i++ { + p.temporal.workers[i].Stop() + } + // destroy worker pools // WP if p.wfP != nil { @@ -249,15 +256,10 @@ func (p *Plugin) Stop(ctx context.Context) error { p.actP.Destroy(ctx) } - // stop receiving tasks - for i := 0; i < len(p.temporal.workers); i++ { - p.temporal.workers[i].Stop() - } - // might be nil if the user didn't set the metrics if p.temporal.tallyCloser != nil { if err := p.temporal.tallyCloser.Close(); err != nil { - p.log.Error("failed to close tally metrics", zap.Error(err)) + p.log.Error("failed to close tally metrics", "error", err) } } @@ -290,7 +292,7 @@ func (p *Plugin) Workers() []*process.State { st, err := process.WorkerProcessState(wfPw[i]) if err != nil { // log the error and continue - p.log.Error("worker process state error", zap.Error(err)) + p.log.Error("worker process state error", "error", err) continue } @@ -301,7 +303,7 @@ func (p *Plugin) Workers() []*process.State { st, err := process.WorkerProcessState(actPw[i]) if err != nil { // log the error and continue - p.log.Error("worker process state error", zap.Error(err)) + p.log.Error("worker process state error", "error", err) continue } @@ -393,7 +395,7 @@ func (p *Plugin) Collects() []*dep.In { p.mu.Lock() if _, exists := p.temporal.interceptors[mdw.Name()]; exists { p.log.Warn("interceptor with this name is already registered, overwriting", - zap.String("name", mdw.Name()), + "name", mdw.Name(), ) } p.temporal.interceptors[mdw.Name()] = mdw @@ -404,7 +406,7 @@ func (p *Plugin) Collects() []*dep.In { p.mu.Lock() if _, exists := p.temporal.dataConverters[pc.Encoding()]; exists { p.log.Warn("data converter with this encoding is already registered, overwriting", - zap.String("encoding", pc.Encoding()), + "encoding", pc.Encoding(), ) } p.temporal.dataConverters[pc.Encoding()] = pc diff --git a/queue/queue.go b/queue/queue.go index 2cee3810..6596718f 100644 --- a/queue/queue.go +++ b/queue/queue.go @@ -3,7 +3,7 @@ package queue import ( "sync" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/temporalio/roadrunner-temporal/v6/internal" "go.temporal.io/api/common/v1" "go.temporal.io/api/failure/v1" ) diff --git a/queue/queue_test.go b/queue/queue_test.go index 6ac14494..ee2b8a97 100644 --- a/queue/queue_test.go +++ b/queue/queue_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/temporalio/roadrunner-temporal/v5/internal" + "github.com/temporalio/roadrunner-temporal/v6/internal" "go.temporal.io/api/common/v1" "go.temporal.io/api/failure/v1" ) diff --git a/rpc.go b/rpc.go index abaf8fc0..d52cf1a6 100644 --- a/rpc.go +++ b/rpc.go @@ -6,10 +6,10 @@ import ( "os" "time" - commonV1 "github.com/roadrunner-server/api/v4/build/common/v1" - protoApi "github.com/roadrunner-server/api/v4/build/temporal/v1" + commonV1 "github.com/roadrunner-server/api-go/v6/common/v1" + protoApi "github.com/roadrunner-server/api-go/v6/temporal/v1" "github.com/roadrunner-server/errors" - "github.com/temporalio/roadrunner-temporal/v5/internal/logger" + "github.com/temporalio/roadrunner-temporal/v6/internal/logger" commonpb "go.temporal.io/api/common/v1" "go.temporal.io/api/enums/v1" "go.temporal.io/api/history/v1" @@ -17,7 +17,6 @@ import ( "go.temporal.io/sdk/client" "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" - "go.uber.org/zap" "google.golang.org/grpc/codes" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" @@ -118,9 +117,9 @@ func (r *rpc) GetWorkflowNames(_ bool, out *[]string) error { func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayResponse) error { r.plugin.log.Debug("replay workflow request", - zap.String("run_id", in.GetWorkflowExecution().GetRunId()), - zap.String("workflow_id", in.GetWorkflowExecution().GetWorkflowId()), - zap.String("workflow_name", in.GetWorkflowType().GetName())) + "run_id", in.GetWorkflowExecution().GetRunId(), + "workflow_id", in.GetWorkflowExecution().GetWorkflowId(), + "workflow_name", in.GetWorkflowType().GetName()) if in.GetWorkflowExecution() == nil || in.GetWorkflowType() == nil { out.Status = &commonV1.Status{ @@ -128,7 +127,7 @@ func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayRes Message: "run_id, workflow_id or workflow_name should not be empty", } - r.plugin.log.Error("replay workflow request", zap.String("error", "run_id, workflow_id or workflow_name should not be empty")) + r.plugin.log.Error("replay workflow request", "error", "run_id, workflow_id or workflow_name should not be empty") return nil } @@ -138,7 +137,7 @@ func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayRes Message: "run_id, workflow_id or workflow_name should not be empty", } - r.plugin.log.Error("replay workflow request", zap.String("error", "run_id, workflow_id or workflow_name should not be empty")) + r.plugin.log.Error("replay workflow request", "error", "run_id, workflow_id or workflow_name should not be empty") return nil } @@ -155,7 +154,7 @@ func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayRes Message: err.Error(), } - r.plugin.log.Error("history iteration error", zap.Error(err)) + r.plugin.log.Error("history iteration error", "error", err) return nil } hist.Events = append(hist.Events, event) @@ -176,14 +175,14 @@ func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayRes DisableAlreadyRegisteredCheck: false, }) - err := replayer.ReplayWorkflowHistory(logger.NewZapAdapter(r.plugin.log), &hist) + err := replayer.ReplayWorkflowHistory(logger.NewSlogAdapter(r.plugin.log), &hist) if err != nil { out.Status = &commonV1.Status{ Code: int32(codes.FailedPrecondition), Message: err.Error(), } - r.plugin.log.Error("replay error", zap.Error(err)) + r.plugin.log.Error("replay error", "error", err) return nil } @@ -198,9 +197,9 @@ func (r *rpc) ReplayWorkflow(in *protoApi.ReplayRequest, out *protoApi.ReplayRes func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi.ReplayResponse) error { r.plugin.log.Debug("replay workflow request", - zap.String("run_id", in.GetWorkflowExecution().GetRunId()), - zap.String("workflow_id", in.GetWorkflowExecution().GetWorkflowId()), - zap.String("save_path", in.GetSavePath())) + "run_id", in.GetWorkflowExecution().GetRunId(), + "workflow_id", in.GetWorkflowExecution().GetWorkflowId(), + "save_path", in.GetSavePath()) if in.GetWorkflowExecution() == nil || in.GetWorkflowType() == nil || in.GetSavePath() == "" { out.Status = &commonV1.Status{ @@ -217,7 +216,7 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Message: "run_id, workflow_id or save_path should not be empty", } - r.plugin.log.Error("replay workflow request", zap.String("error", "run_id, workflow_id or save_path should not be empty")) + r.plugin.log.Error("replay workflow request", "error", "run_id, workflow_id or save_path should not be empty") return nil } @@ -228,14 +227,14 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Message: err.Error(), } - r.plugin.log.Error("failed to create the file", zap.Error(err)) + r.plugin.log.Error("failed to create the file", "error", err) return nil } defer func() { err = file.Close() if err != nil { - r.plugin.log.Error("failed to close the file", zap.Error(err)) + r.plugin.log.Error("failed to close the file", "error", err) } }() @@ -253,7 +252,7 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Message: errn.Error(), } - r.plugin.log.Error("history iteration error", zap.Error(errn)) + r.plugin.log.Error("history iteration error", "error", errn) return nil } @@ -267,7 +266,7 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Message: err.Error(), } - r.plugin.log.Error("history marshal error", zap.Error(err)) + r.plugin.log.Error("history marshal error", "error", err) return nil } @@ -278,7 +277,7 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Message: err.Error(), } - r.plugin.log.Error("history marshal error", zap.Error(err)) + r.plugin.log.Error("history marshal error", "error", err) return nil } @@ -286,16 +285,16 @@ func (r *rpc) DownloadWorkflowHistory(in *protoApi.ReplayRequest, out *protoApi. Code: int32(codes.OK), } - r.plugin.log.Debug("history saved", zap.String("location", in.GetSavePath())) + r.plugin.log.Debug("history saved", "location", in.GetSavePath()) return nil } func (r *rpc) ReplayFromJSON(in *protoApi.ReplayRequest, out *protoApi.ReplayResponse) error { r.plugin.log.Debug("replay from JSON request", - zap.String("workflow_name", in.GetWorkflowType().GetName()), - zap.String("save_path", in.GetSavePath()), - zap.Int64("last_event_id", in.GetLastEventId()), + "workflow_name", in.GetWorkflowType().GetName(), + "save_path", in.GetSavePath(), + "last_event_id", in.GetLastEventId(), ) if in.GetWorkflowType() == nil || in.GetSavePath() == "" { @@ -304,7 +303,7 @@ func (r *rpc) ReplayFromJSON(in *protoApi.ReplayRequest, out *protoApi.ReplayRes Message: "workflow_name and save_path should not be empty", } - r.plugin.log.Error("replay from JSON request", zap.String("error", "workflow_name and save_path should not be empty")) + r.plugin.log.Error("replay from JSON request", "error", "workflow_name and save_path should not be empty") return nil } @@ -314,7 +313,7 @@ func (r *rpc) ReplayFromJSON(in *protoApi.ReplayRequest, out *protoApi.ReplayRes Message: "workflow_name should not be empty", } - r.plugin.log.Error("replay from JSON request", zap.String("error", "workflow_name should not be empty")) + r.plugin.log.Error("replay from JSON request", "error", "workflow_name should not be empty") return nil } @@ -336,26 +335,26 @@ func (r *rpc) ReplayFromJSON(in *protoApi.ReplayRequest, out *protoApi.ReplayRes switch in.GetLastEventId() { // we don't have last event ID case 0: - err := replayer.ReplayWorkflowHistoryFromJSONFile(logger.NewZapAdapter(r.plugin.log), in.GetSavePath()) + err := replayer.ReplayWorkflowHistoryFromJSONFile(logger.NewSlogAdapter(r.plugin.log), in.GetSavePath()) if err != nil { out.Status = &commonV1.Status{ Code: int32(codes.FailedPrecondition), Message: err.Error(), } - r.plugin.log.Error("replay from JSON request", zap.Error(err)) + r.plugin.log.Error("replay from JSON request", "error", err) return nil } default: // we have last event ID - err := replayer.ReplayPartialWorkflowHistoryFromJSONFile(logger.NewZapAdapter(r.plugin.log), in.GetSavePath(), in.GetLastEventId()) + err := replayer.ReplayPartialWorkflowHistoryFromJSONFile(logger.NewSlogAdapter(r.plugin.log), in.GetSavePath(), in.GetLastEventId()) if err != nil { out.Status = &commonV1.Status{ Code: int32(codes.FailedPrecondition), Message: err.Error(), } - r.plugin.log.Error("replay from JSON request (partial workflow history)", zap.Int64("id", in.GetLastEventId()), zap.Error(err)) + r.plugin.log.Error("replay from JSON request (partial workflow history)", "id", in.GetLastEventId(), "error", err) return nil } } @@ -371,7 +370,7 @@ func (r *rpc) ReplayFromJSON(in *protoApi.ReplayRequest, out *protoApi.ReplayRes func (r *rpc) ReplayWorkflowHistory(in *protoApi.History, out *protoApi.ReplayResponse) error { r.plugin.log.Debug("replay from workflow history request", - zap.String("workflow_name", in.GetWorkflowType().GetName()), + "workflow_name", in.GetWorkflowType().GetName(), ) if in.GetHistory() == nil || in.GetWorkflowType().GetName() == "" { @@ -399,14 +398,14 @@ func (r *rpc) ReplayWorkflowHistory(in *protoApi.History, out *protoApi.ReplayRe DisableAlreadyRegisteredCheck: false, }) - err := replayer.ReplayWorkflowHistory(logger.NewZapAdapter(r.plugin.log), in.GetHistory()) + err := replayer.ReplayWorkflowHistory(logger.NewSlogAdapter(r.plugin.log), in.GetHistory()) if err != nil { out.Status = &commonV1.Status{ Code: int32(codes.FailedPrecondition), Message: err.Error(), } - r.plugin.log.Error("replay workflow history", zap.Error(err)) + r.plugin.log.Error("replay workflow history", "error", err) return nil } diff --git a/status.go b/status.go index 3b647eba..a87e8da0 100644 --- a/status.go +++ b/status.go @@ -3,9 +3,9 @@ package rrtemporal import ( "net/http" - "github.com/roadrunner-server/pool/fsm" + "github.com/roadrunner-server/pool/v2/fsm" - "github.com/roadrunner-server/api/v4/plugins/v1/status" + "github.com/roadrunner-server/api-plugins/v6/status" ) // Status return status of the particular plugin diff --git a/tests/general/disaster_test.go b/tests/general/disaster_test.go index 05f46d8c..6fa5aadd 100644 --- a/tests/general/disaster_test.go +++ b/tests/general/disaster_test.go @@ -12,8 +12,8 @@ import ( "tests/helpers" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" - "github.com/roadrunner-server/pool/state/process" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" + "github.com/roadrunner-server/pool/v2/state/process" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.temporal.io/sdk/client" diff --git a/tests/general/general_test.go b/tests/general/general_test.go index 133807a0..d36617e0 100644 --- a/tests/general/general_test.go +++ b/tests/general/general_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/require" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" - "github.com/roadrunner-server/pool/state/process" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" + "github.com/roadrunner-server/pool/v2/state/process" "tests/helpers" diff --git a/tests/general/hp_test.go b/tests/general/hp_test.go index a7b1edca..a943ee48 100644 --- a/tests/general/hp_test.go +++ b/tests/general/hp_test.go @@ -13,7 +13,7 @@ import ( "tests/helpers" "time" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" "github.com/stretchr/testify/require" "go.temporal.io/api/common/v1" diff --git a/tests/general/plugin_status_test.go b/tests/general/plugin_status_test.go index b0a1173a..c6427f5e 100644 --- a/tests/general/plugin_status_test.go +++ b/tests/general/plugin_status_test.go @@ -12,13 +12,13 @@ import ( "testing" "time" - "github.com/roadrunner-server/config/v5" + "github.com/roadrunner-server/config/v6" "github.com/roadrunner-server/endure/v2" - "github.com/roadrunner-server/logger/v5" - "github.com/roadrunner-server/server/v5" - "github.com/roadrunner-server/status/v5" + "github.com/roadrunner-server/logger/v6" + "github.com/roadrunner-server/server/v6" + "github.com/roadrunner-server/status/v6" "github.com/stretchr/testify/require" - rrtemporal "github.com/temporalio/roadrunner-temporal/v5" + rrtemporal "github.com/temporalio/roadrunner-temporal/v6" "github.com/stretchr/testify/assert" ) diff --git a/tests/general/rpc_test.go b/tests/general/rpc_test.go index 74c6af13..f4327706 100644 --- a/tests/general/rpc_test.go +++ b/tests/general/rpc_test.go @@ -10,8 +10,8 @@ import ( "tests/helpers" "time" - protoApi "github.com/roadrunner-server/api/v4/build/temporal/v1" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" + protoApi "github.com/roadrunner-server/api-go/v6/temporal/v1" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.temporal.io/api/common/v1" diff --git a/tests/go.mod b/tests/go.mod index c42fb47a..994b04fb 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -5,29 +5,28 @@ go 1.26.5 require ( github.com/fatih/color v1.19.0 github.com/pborman/uuid v1.2.1 - github.com/roadrunner-server/api/v4 v4.24.0 - github.com/roadrunner-server/config/v5 v5.1.9 + github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14 + github.com/roadrunner-server/config/v6 v6.0.0-beta.3 github.com/roadrunner-server/endure/v2 v2.6.2 - github.com/roadrunner-server/goridge/v3 v3.8.3 - github.com/roadrunner-server/informer/v5 v5.1.9 - github.com/roadrunner-server/logger/v5 v5.1.9 - github.com/roadrunner-server/pool v1.1.3 - github.com/roadrunner-server/resetter/v5 v5.1.9 - github.com/roadrunner-server/rpc/v5 v5.1.9 - github.com/roadrunner-server/server/v5 v5.2.10 - github.com/roadrunner-server/status/v5 v5.1.9 + github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3 + github.com/roadrunner-server/informer/v6 v6.0.0-beta.4 + github.com/roadrunner-server/logger/v6 v6.0.0-beta.3 + github.com/roadrunner-server/pool/v2 v2.0.0-beta.1 + github.com/roadrunner-server/resetter/v6 v6.0.0-beta.5 + github.com/roadrunner-server/rpc/v6 v6.0.0-beta.5 + github.com/roadrunner-server/server/v6 v6.0.0-beta.6 + github.com/roadrunner-server/status/v6 v6.0.0-beta.7 github.com/stretchr/testify v1.12.1 - github.com/temporalio/roadrunner-temporal/v5 v5.11.0 + github.com/temporalio/roadrunner-temporal/v6 v6.0.0 go.opentelemetry.io/otel/sdk v1.45.0 go.temporal.io/api v1.63.5 go.temporal.io/sdk v1.48.0 go.temporal.io/sdk/contrib/opentelemetry v0.8.1 - go.uber.org/zap v1.28.0 ) replace github.com/uber-go/tally/v4 => github.com/uber-go/tally/v4 v4.1.10 -replace github.com/temporalio/roadrunner-temporal/v5 => ../ +replace github.com/temporalio/roadrunner-temporal/v6 => ../ require ( github.com/beorn7/perks v1.0.1 // indirect @@ -66,6 +65,7 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.70.1 // indirect github.com/prometheus/procfs v0.21.1 // indirect + github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2 // indirect github.com/roadrunner-server/errors v1.5.0 // indirect github.com/roadrunner-server/events v1.0.1 // indirect github.com/roadrunner-server/tcplisten v1.5.2 // indirect @@ -84,8 +84,6 @@ require ( github.com/tklauser/numcpus v0.12.0 // indirect github.com/twmb/murmur3 v1.1.8 // indirect github.com/uber-go/tally/v4 v4.1.17 // indirect - github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel v1.45.0 // indirect @@ -96,6 +94,7 @@ require ( go.temporal.io/server v1.31.2 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.28.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/net v0.57.0 // indirect golang.org/x/sync v0.22.0 // indirect @@ -106,5 +105,4 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea // indirect google.golang.org/grpc v1.83.0 // indirect google.golang.org/protobuf v1.36.12 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) diff --git a/tests/go.sum b/tests/go.sum index 271bf490..c6053c2b 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -215,32 +215,34 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= -github.com/roadrunner-server/api/v4 v4.24.0 h1:99lN8nu7aD76d1fru4+MZkf9m8+YJ22Jy+qVoDwn4OY= -github.com/roadrunner-server/api/v4 v4.24.0/go.mod h1:O0LputszJr6NXMw0SKyWaiS/C9K6JVh9HV2BHKXeosA= -github.com/roadrunner-server/config/v5 v5.1.9 h1:ReWwts/prEvuC4yVJ0BRDmY5sxw/1c+hGTSdJ71hIQU= -github.com/roadrunner-server/config/v5 v5.1.9/go.mod h1:R6YyTWahW61tWHOI2BfdkQU/0Zc/2d6/JbJ/KEvq8F8= +github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14 h1:sTskv/3ImOZlUdtHuj9uT24gm1gQl/qU8rFNvn3MzhU= +github.com/roadrunner-server/api-go/v6 v6.0.0-beta.14/go.mod h1:Y4rsabWjr4Y10Jg6H8J5NDitQqlnXmGhCdgR+zyLYkI= +github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2 h1:GqsZzWQ5jMXRF1O/b8IqFz9PLpS7Ui0K4OyACLql2MI= +github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2/go.mod h1:2v4yUK5Kvbvq8C3IkDoBkuamq9h+7i/JLjyf7k1j5JM= +github.com/roadrunner-server/config/v6 v6.0.0-beta.3 h1:G0EUzJ6Yw4UnleM6BhnOBbYPXKDHRmCJiGhC3nXDBwI= +github.com/roadrunner-server/config/v6 v6.0.0-beta.3/go.mod h1:eIB+c29njpcKokXrxe483FbQOBSTNGvU3hhC6W/qYSU= github.com/roadrunner-server/endure/v2 v2.6.2 h1:sIB4kTyE7gtT3fDhuYWUYn6Vt/dcPtiA6FoNS1eS+84= github.com/roadrunner-server/endure/v2 v2.6.2/go.mod h1:t/2+xpNYgGBwhzn83y2MDhvhZ19UVq1REcvqn7j7RB8= github.com/roadrunner-server/errors v1.5.0 h1:unG7LKIZrSzkCCF3YLRLA5VyqE0KKomofXVJUXJe00g= github.com/roadrunner-server/errors v1.5.0/go.mod h1:g9fo/T2C13cWRDR9PW1r0ZAOSQfNhWAZawyfkGiaHuI= github.com/roadrunner-server/events v1.0.1 h1:waCkKhxhzdK3VcI1xG22l+h+0J+Nfdpxjhyy01Un+kI= github.com/roadrunner-server/events v1.0.1/go.mod h1:WZRqoEVaFm209t52EuoT7ISUtvX6BrCi6bI/7pjkVC0= -github.com/roadrunner-server/goridge/v3 v3.8.3 h1:XmjrOFnI6ZbQTPaP39DEk8KwLUNTgjluK3pcZaW6ixQ= -github.com/roadrunner-server/goridge/v3 v3.8.3/go.mod h1:4TZU8zgkKIZCsH51qwGMpvyXCT59u/8z6q8sCe4ZGAQ= -github.com/roadrunner-server/informer/v5 v5.1.9 h1:yl334LMqUoWXfeP4299HgY9G7mq6kX6FVCSwT+cYdfQ= -github.com/roadrunner-server/informer/v5 v5.1.9/go.mod h1:JPzSsDjLHExdQ9SbT9e8H/oB7pajgCScL/G70saQzSA= -github.com/roadrunner-server/logger/v5 v5.1.9 h1:3Kn+NYXF7Ww5LvkwMZwkv1q99t5qusIPBsreRJL08JI= -github.com/roadrunner-server/logger/v5 v5.1.9/go.mod h1:hwct/TWTmxYsVzowLx4g9HkY5z2/gpYOC+UN8btsrAA= -github.com/roadrunner-server/pool v1.1.3 h1:KMsiL6yuYBWGk73bdO0akwP+fJ63bxDF972JukCGsxI= -github.com/roadrunner-server/pool v1.1.3/go.mod h1:8ceC7NvZKJRciv+KJmcyk5CeDugoel6GD+crm5kBFW0= -github.com/roadrunner-server/resetter/v5 v5.1.9 h1:rH1nxkgvItbMEp1/JFZqcijOkkav4zo0E4wcVXBcXa8= -github.com/roadrunner-server/resetter/v5 v5.1.9/go.mod h1:P5TfzCGQMNsUDPTrjOU7XFLdRz+DtFH/FmRla+lUF94= -github.com/roadrunner-server/rpc/v5 v5.1.9 h1:AbRd2xEkWY8N3J4GUhoDeL+pnfwzKHazV4k40jZ+YDk= -github.com/roadrunner-server/rpc/v5 v5.1.9/go.mod h1:TtbPY1cPvL46Mk9Dh4qwx33WO4R3m1lZkgL2q2MfHtA= -github.com/roadrunner-server/server/v5 v5.2.10 h1:IshR3mlXJ/fh+zY17tN3Q7GgaanMzA7H9wwEz4PxCSA= -github.com/roadrunner-server/server/v5 v5.2.10/go.mod h1:oxXhRo2EDykCk8ujhdjyJCb2rPpoTt8AVy46RHRfeeo= -github.com/roadrunner-server/status/v5 v5.1.9 h1:TxDCj88Y7Bzcwbv8zwvNV1dE25n2x7IYw5M+kqadZWk= -github.com/roadrunner-server/status/v5 v5.1.9/go.mod h1:9v53l4V680aIPinjTFHr8ZKEGwvFPEeHTFCaJkWjejA= +github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3 h1:+kUw00/fpqwdMWrPMYW+OZH3O4gEar8hqrY7I+nAztA= +github.com/roadrunner-server/goridge/v4 v4.0.0-beta.3/go.mod h1:1aHppV68y/VqRED/AsfNg59sft9aQOhqgr5Z5n49jbM= +github.com/roadrunner-server/informer/v6 v6.0.0-beta.4 h1:/jl+65LdW2n0hg269obqQciTb/vrmN516pjGprFfSuU= +github.com/roadrunner-server/informer/v6 v6.0.0-beta.4/go.mod h1:EGsQJsRsKnEGlQD+UBKAQuSlotJIJiiBYsxWHPb4rpM= +github.com/roadrunner-server/logger/v6 v6.0.0-beta.3 h1:eoJKXAUSyykDfVX6eTUhmAn6Y8pS/LyI5fDP4H+G5rQ= +github.com/roadrunner-server/logger/v6 v6.0.0-beta.3/go.mod h1:MwHb3AbltHYtu7nRpml5NeYu7O+W8rCpDBeNTTEoE1M= +github.com/roadrunner-server/pool/v2 v2.0.0-beta.1 h1:jpYXFtdD6QGAdAGPgMxrNi3j1CegCRpb2y+A+3GnXFA= +github.com/roadrunner-server/pool/v2 v2.0.0-beta.1/go.mod h1:Bo1wT7RtL3eyQHXBUohNhtj/yAmRt6Rq8smuBg5pWkY= +github.com/roadrunner-server/resetter/v6 v6.0.0-beta.5 h1:ia8qeVmZ1GbxMwvpLDUeJaU0F657NeRn6T2ctCrOvfs= +github.com/roadrunner-server/resetter/v6 v6.0.0-beta.5/go.mod h1:0RUrX6bTtX4GEXP4QIbzMsW+KieFOqjogPe9u9pz9AM= +github.com/roadrunner-server/rpc/v6 v6.0.0-beta.5 h1:FjwXfznbmyCEKFUHkxnvK8yo1HQKAQk+7fiPhSYC27E= +github.com/roadrunner-server/rpc/v6 v6.0.0-beta.5/go.mod h1:z387hZZOEJ3+bB8iW1PEAEXF3jUUb/dDLDnVSc1CNNQ= +github.com/roadrunner-server/server/v6 v6.0.0-beta.6 h1:CPtH4eIYkeRKi5cPXxb0+J+LI824cqhIGXAfcH+nkjA= +github.com/roadrunner-server/server/v6 v6.0.0-beta.6/go.mod h1:SbODuCzC2gcbFhAmJDWvjf34pPrUWP5NxxVsTRQDuZ4= +github.com/roadrunner-server/status/v6 v6.0.0-beta.7 h1:7adpXfaIY2nIt4P58avZH05y4R3cKXKLux16SFYG/+g= +github.com/roadrunner-server/status/v6 v6.0.0-beta.7/go.mod h1:7EjsT+ULghsemlRpKoks250yJNWLdR/R8Ah/N5Q1NQE= github.com/roadrunner-server/tcplisten v1.5.2 h1:nn8yXYrhRDkfQ9AAu4V075uT4fZRmOnpxkawgE+bWPA= github.com/roadrunner-server/tcplisten v1.5.2/go.mod h1:DufGBz7Dlx2KrNe/4RukEvGMTqZKB0Uve1GztwcyyR8= github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= @@ -294,10 +296,6 @@ github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg= github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= github.com/uber-go/tally/v4 v4.1.10 h1:2GSX7Tmq26wjAvOtQEc5EvRROIkX2OX4vpROt6mlRLM= github.com/uber-go/tally/v4 v4.1.10/go.mod h1:pPR56rjthjtLB8xQlEx2I1VwAwRGCh/i4xMUcmG+6z4= -github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= -github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= -github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -492,8 +490,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/validator.v2 v2.0.0-20200605151824-2b28d334fa05/go.mod h1:o4V0GXN9/CAmCsvJ0oXYZvrZOe7syiDZSN1GWGZTGzc= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/tests/helpers/helpers.go b/tests/helpers/helpers.go index 2707bfad..b0437af3 100644 --- a/tests/helpers/helpers.go +++ b/tests/helpers/helpers.go @@ -11,25 +11,23 @@ import ( "testing" "time" - "github.com/roadrunner-server/status/v5" + "github.com/roadrunner-server/status/v6" - configImpl "github.com/roadrunner-server/config/v5" + configImpl "github.com/roadrunner-server/config/v6" "github.com/roadrunner-server/endure/v2" - "github.com/roadrunner-server/informer/v5" - "github.com/roadrunner-server/logger/v5" - "github.com/roadrunner-server/resetter/v5" - "github.com/roadrunner-server/rpc/v5" - "github.com/roadrunner-server/server/v5" + "github.com/roadrunner-server/informer/v6" + "github.com/roadrunner-server/logger/v6" + "github.com/roadrunner-server/resetter/v6" + "github.com/roadrunner-server/rpc/v6" + "github.com/roadrunner-server/server/v6" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - roadrunnerTemporal "github.com/temporalio/roadrunner-temporal/v5" - "github.com/temporalio/roadrunner-temporal/v5/dataconverter" + roadrunnerTemporal "github.com/temporalio/roadrunner-temporal/v6" + "github.com/temporalio/roadrunner-temporal/v6/dataconverter" "go.temporal.io/api/enums/v1" "go.temporal.io/api/history/v1" temporalClient "go.temporal.io/sdk/client" "go.temporal.io/sdk/converter" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" ) const ( @@ -48,51 +46,46 @@ type TestServer struct { } type log struct { - zl *zap.Logger + sl *slog.Logger } -// NewZapAdapter ... which uses general log interface -func newZapAdapter(zapLogger *zap.Logger) *log { +// newSlogAdapter wraps an slog.Logger into the Temporal SDK log interface. +func newSlogAdapter(l *slog.Logger) *log { return &log{ - zl: zapLogger.WithOptions(zap.AddCallerSkip(1)), + sl: l, } } func (l *log) Debug(msg string, keyvals ...any) { - l.zl.Debug(msg, l.fields(keyvals)...) + l.sl.Debug(msg, l.args(keyvals)...) } func (l *log) Info(msg string, keyvals ...any) { - l.zl.Info(msg, l.fields(keyvals)...) + l.sl.Info(msg, l.args(keyvals)...) } func (l *log) Warn(msg string, keyvals ...any) { - l.zl.Warn(msg, l.fields(keyvals)...) + l.sl.Warn(msg, l.args(keyvals)...) } func (l *log) Error(msg string, keyvals ...any) { - l.zl.Error(msg, l.fields(keyvals)...) + l.sl.Error(msg, l.args(keyvals)...) } -func (l *log) fields(keyvals []any) []zap.Field { +func (l *log) args(keyvals []any) []any { // we should have an even number of keys and values if len(keyvals)%2 != 0 { - return []zap.Field{zap.Error(fmt.Errorf("odd number of keyvals pairs: %v", keyvals))} + return []any{"error", fmt.Errorf("odd number of keyvals pairs: %v", keyvals)} } - zf := make([]zap.Field, len(keyvals)/2) - j := 0 + // slog consumes a single element for a non-string key, which would shift every pair after it for i := 0; i < len(keyvals); i += 2 { - key, ok := keyvals[i].(string) - if !ok { - key = fmt.Sprintf("%v", keyvals[i]) + if _, ok := keyvals[i].(string); !ok { + keyvals[i] = fmt.Sprintf("%v", keyvals[i]) } - - zf[j] = zap.Any(key, keyvals[i+1]) - j++ } - return zf + return keyvals } func NewTestServer(t *testing.T, stopCh chan struct{}, wg *sync.WaitGroup, configPath string) *TestServer { @@ -141,7 +134,7 @@ func NewTestServer(t *testing.T, stopCh chan struct{}, wg *sync.WaitGroup, confi HostPort: "127.0.0.1:7233", Namespace: "default", DataConverter: dc, - Logger: newZapAdapter(initLogger()), + Logger: newSlogAdapter(initLogger()), }) if err != nil { t.Fatal(err) @@ -215,7 +208,7 @@ func NewTestServerTLS(t *testing.T, stopCh chan struct{}, wg *sync.WaitGroup, co HostPort: "127.0.0.1:7233", Namespace: "default", DataConverter: dc, - Logger: newZapAdapter(initLogger()), + Logger: newSlogAdapter(initLogger()), ConnectionOptions: temporalClient.ConnectionOptions{ TLS: &tls.Config{ MinVersion: tls.VersionTLS12, @@ -285,7 +278,7 @@ func NewTestServerWithInterceptor(t *testing.T, stopCh chan struct{}, wg *sync.W HostPort: "127.0.0.1:7233", Namespace: "default", DataConverter: dc, - Logger: newZapAdapter(initLogger()), + Logger: newSlogAdapter(initLogger()), }) require.NoError(t, err) @@ -345,7 +338,7 @@ func NewTestServerWithDataConverter(t *testing.T, stopCh chan struct{}, wg *sync HostPort: "127.0.0.1:7233", Namespace: "default", DataConverter: dc, - Logger: newZapAdapter(initLogger()), + Logger: newSlogAdapter(initLogger()), }) require.NoError(t, err) @@ -402,7 +395,7 @@ func NewTestServerWithOtelInterceptor(t *testing.T, stopCh chan struct{}, wg *sy HostPort: "127.0.0.1:7233", Namespace: "default", DataConverter: dc, - Logger: newZapAdapter(initLogger()), + Logger: newSlogAdapter(initLogger()), }) require.NoError(t, err) @@ -461,29 +454,8 @@ func (s *TestServer) AssertNotContainsEvent(client temporalClient.Client, t *tes } } -func initLogger() *zap.Logger { - cfg := zap.Config{ - Level: zap.NewAtomicLevelAt(zap.ErrorLevel), - Encoding: "console", - EncoderConfig: zapcore.EncoderConfig{ - MessageKey: "message", - LevelKey: "level", - TimeKey: "time", - CallerKey: "caller", - NameKey: "name", - StacktraceKey: "stack", - EncodeLevel: zapcore.CapitalLevelEncoder, - EncodeTime: zapcore.ISO8601TimeEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - }, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } - - l, err := cfg.Build(zap.AddCaller()) - if err != nil { - panic(err) - } - - return l +func initLogger() *slog.Logger { + return slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ + Level: slog.LevelError, + })) } diff --git a/tests/mock/doc.go b/tests/mock/doc.go index a9c49222..b1620acc 100644 --- a/tests/mock/doc.go +++ b/tests/mock/doc.go @@ -1,3 +1,4 @@ -// Package mocklogger provides test logging infrastructure including an in-memory -// zapcore.Core observer and a zap.Logger implementation compatible with the Endure container lifecycle. +// Package mocklogger provides a slog logger that captures records in memory for +// assertion. It implements the RoadRunner Logger interface and registers with +// the endure dependency injection container in place of the logger plugin. package mocklogger diff --git a/tests/mock/logger.go b/tests/mock/logger.go index 9bc251fe..ed473598 100644 --- a/tests/mock/logger.go +++ b/tests/mock/logger.go @@ -1,64 +1,64 @@ package mocklogger import ( + "log/slog" + "github.com/roadrunner-server/endure/v2/dep" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" ) -type ZapLoggerMock struct { - l *zap.Logger +type SlogLoggerMock struct { + l *slog.Logger } type Logger interface { - NamedLogger(string) *zap.Logger + NamedLogger(string) *slog.Logger } -func ZapTestLogger(enab zapcore.LevelEnabler) (*ZapLoggerMock, *ObservedLogs) { - core, logs := New(enab) - obsLog := zap.New(core, zap.Development()) +func SlogTestLogger(level slog.Level) (*SlogLoggerMock, *ObservedLogs) { + handler, logs := NewObserverHandler(level) + obsLog := slog.New(handler) - return &ZapLoggerMock{ + return &SlogLoggerMock{ l: obsLog, }, logs } -func (z *ZapLoggerMock) Init() error { +func (z *SlogLoggerMock) Init() error { return nil } -func (z *ZapLoggerMock) Serve() chan error { +func (z *SlogLoggerMock) Serve() chan error { return make(chan error, 1) } -func (z *ZapLoggerMock) Stop() error { - return z.l.Sync() +func (z *SlogLoggerMock) Stop() error { + return nil } -func (z *ZapLoggerMock) Provides() []*dep.Out { +func (z *SlogLoggerMock) Provides() []*dep.Out { return []*dep.Out{ dep.Bind((*Logger)(nil), z.ProvideLogger), } } -func (z *ZapLoggerMock) Weight() uint { +func (z *SlogLoggerMock) Weight() uint { return 100 } -func (z *ZapLoggerMock) ProvideLogger() *Log { +func (z *SlogLoggerMock) ProvideLogger() *Log { return NewLogger(z.l) } type Log struct { - base *zap.Logger + base *slog.Logger } -func NewLogger(log *zap.Logger) *Log { +func NewLogger(log *slog.Logger) *Log { return &Log{ base: log, } } -func (l *Log) NamedLogger(string) *zap.Logger { +func (l *Log) NamedLogger(string) *slog.Logger { return l.base } diff --git a/tests/mock/observer.go b/tests/mock/observer.go index 061cec7e..7a24c1fc 100644 --- a/tests/mock/observer.go +++ b/tests/mock/observer.go @@ -1,47 +1,16 @@ package mocklogger -// Copyright (c) 2017 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - import ( + "context" + "log/slog" "strings" "sync" - "time" - - "go.uber.org/zap/zapcore" ) -// An LoggedEntry is an encoding-agnostic representation of a log message. -// Field availability is context dependant. +// LoggedEntry is a representation of a log record captured by the observer. type LoggedEntry struct { - zapcore.Entry - Context []zapcore.Field -} - -// ContextMap returns a map for all fields in Context. -func (e LoggedEntry) ContextMap() map[string]any { - encoder := zapcore.NewMapObjectEncoder() - for _, f := range e.Context { - f.AddTo(encoder) - } - return encoder.Fields + Level slog.Level + Message string } // ObservedLogs is a concurrency-safe, ordered collection of observed logs. @@ -58,142 +27,59 @@ func (o *ObservedLogs) Len() int { return n } -// All returns a copy of all the observed logs. -func (o *ObservedLogs) All() []LoggedEntry { - o.mu.RLock() - ret := make([]LoggedEntry, len(o.logs)) - copy(ret, o.logs) - o.mu.RUnlock() - return ret -} - -// TakeAll returns a copy of all the observed logs, and truncates the observed -// slice. -func (o *ObservedLogs) TakeAll() []LoggedEntry { - o.mu.Lock() - ret := o.logs - o.logs = nil - o.mu.Unlock() - return ret -} - -// AllUntimed returns a copy of all the observed logs, but overwrites the -// observed timestamps with time.Time's zero value. This is useful when making -// assertions in tests. -func (o *ObservedLogs) AllUntimed() []LoggedEntry { - ret := o.All() - for i := range ret { - ret[i].Time = time.Time{} - } - return ret -} - -// FilterLevelExact filters entries to those logged at exactly the given level. -func (o *ObservedLogs) FilterLevelExact(level zapcore.Level) *ObservedLogs { - return o.Filter(func(e LoggedEntry) bool { - return e.Level == level - }) -} - -// FilterMessage filters entries to those that have the specified message. -func (o *ObservedLogs) FilterMessage(msg string) *ObservedLogs { - return o.Filter(func(e LoggedEntry) bool { - return e.Message == msg - }) -} - -// FilterMessageSnippet filters entries to those that have a message containing the specified snippet. +// FilterMessageSnippet returns the entries whose message contains the snippet. func (o *ObservedLogs) FilterMessageSnippet(snippet string) *ObservedLogs { - return o.Filter(func(e LoggedEntry) bool { - return strings.Contains(e.Message, snippet) - }) -} - -// FilterField filters entries to those that have the specified field. -func (o *ObservedLogs) FilterField(field zapcore.Field) *ObservedLogs { - return o.Filter(func(e LoggedEntry) bool { - for _, ctxField := range e.Context { - if ctxField.Equals(field) { - return true - } - } - return false - }) -} - -// FilterFieldKey filters entries to those that have the specified key. -func (o *ObservedLogs) FilterFieldKey(key string) *ObservedLogs { - return o.Filter(func(e LoggedEntry) bool { - for _, ctxField := range e.Context { - if ctxField.Key == key { - return true - } - } - return false - }) -} - -// Filter returns a copy of this ObservedLogs containing only those entries -// for which the provided function returns true. -func (o *ObservedLogs) Filter(keep func(LoggedEntry) bool) *ObservedLogs { o.mu.RLock() defer o.mu.RUnlock() var filtered []LoggedEntry for _, entry := range o.logs { - if keep(entry) { + if strings.Contains(entry.Message, snippet) { filtered = append(filtered, entry) } } + return &ObservedLogs{logs: filtered} } -func (o *ObservedLogs) add(log LoggedEntry) { +func (o *ObservedLogs) add(entry LoggedEntry) { o.mu.Lock() - o.logs = append(o.logs, log) + o.logs = append(o.logs, entry) o.mu.Unlock() } -// New creates a new Core that buffers logs in memory (without any encoding). -// It's particularly useful in tests. -func New(enab zapcore.LevelEnabler) (zapcore.Core, *ObservedLogs) { - ol := &ObservedLogs{} - return &contextObserver{ - LevelEnabler: enab, - logs: ol, - }, ol +// observerHandler is an slog.Handler that captures the level and the message of +// every record. Attributes are not recorded, nothing asserts on them. +type observerHandler struct { + level slog.Level + logs *ObservedLogs } -type contextObserver struct { - zapcore.LevelEnabler - logs *ObservedLogs - context []zapcore.Field +// NewObserverHandler creates a new slog.Handler that buffers logs in memory. +func NewObserverHandler(level slog.Level) (slog.Handler, *ObservedLogs) { + ol := &ObservedLogs{} + return &observerHandler{ + level: level, + logs: ol, + }, ol } -func (co *contextObserver) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry { - if co.Enabled(ent.Level) { - return ce.AddCore(ent, co) - } - return ce +func (h *observerHandler) Enabled(_ context.Context, level slog.Level) bool { + return level >= h.level } -func (co *contextObserver) With(fields []zapcore.Field) zapcore.Core { - return &contextObserver{ - LevelEnabler: co.LevelEnabler, - logs: co.logs, - context: append(co.context[:len(co.context):len(co.context)], fields...), - } +func (h *observerHandler) Handle(_ context.Context, r slog.Record) error { + h.logs.add(LoggedEntry{ + Level: r.Level, + Message: r.Message, + }) + return nil } -func (co *contextObserver) Write(ent zapcore.Entry, fields []zapcore.Field) error { - all := make([]zapcore.Field, 0, len(fields)+len(co.context)) - all = append(all, co.context...) - all = append(all, fields...) - co.logs.add(LoggedEntry{ent, all}) - - return nil +func (h *observerHandler) WithAttrs(_ []slog.Attr) slog.Handler { + return h } -func (co *contextObserver) Sync() error { - return nil +func (h *observerHandler) WithGroup(_ string) slog.Handler { + return h } diff --git a/tests/tls/disaster_tls_test.go b/tests/tls/disaster_tls_test.go index 857a7458..6f529e88 100644 --- a/tests/tls/disaster_tls_test.go +++ b/tests/tls/disaster_tls_test.go @@ -12,8 +12,8 @@ import ( "tests/helpers" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" - "github.com/roadrunner-server/pool/state/process" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" + "github.com/roadrunner-server/pool/v2/state/process" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.temporal.io/sdk/client" diff --git a/tests/tls/hp_tls_test.go b/tests/tls/hp_tls_test.go index 6cd83492..1af2d302 100644 --- a/tests/tls/hp_tls_test.go +++ b/tests/tls/hp_tls_test.go @@ -14,7 +14,7 @@ import ( "tests/helpers" "github.com/fatih/color" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.temporal.io/api/common/v1" diff --git a/tests/updates/updates_replay_test.go b/tests/updates/updates_replay_test.go index 39c6f561..a7d1120d 100644 --- a/tests/updates/updates_replay_test.go +++ b/tests/updates/updates_replay_test.go @@ -10,8 +10,8 @@ import ( "tests/helpers" "time" - protoApi "github.com/roadrunner-server/api/v4/build/temporal/v1" - goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc" + protoApi "github.com/roadrunner-server/api-go/v6/temporal/v1" + goridgeRpc "github.com/roadrunner-server/goridge/v4/pkg/rpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.temporal.io/api/common/v1"