Skip to content

Log Node ID with node map logs #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pool/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ const (
func AddNode(ctx context.Context, name string, rdb *redis.Client, opts ...NodeOption) (*Node, error) {
o := parseOptions(opts...)
logger := o.logger
nodeID := ulid.Make().String()
if logger == nil {
logger = pulse.NoopLogger()
} else {
logger = logger.WithPrefix("pool", name, "node", nodeID)
}
wsm, err := rmap.Join(ctx, shutdownMapName(name), rdb, rmap.WithLogger(logger))
if err != nil {
Expand All @@ -109,7 +112,6 @@ func AddNode(ctx context.Context, name string, rdb *redis.Client, opts ...NodeOp
if err != nil {
return nil, fmt.Errorf("failed to create pool job stream %q: %w", poolStreamName(name), err)
}
nodeID := ulid.Make().String()
var (
wm *rmap.Map
jm *rmap.Map
Expand Down Expand Up @@ -177,10 +179,10 @@ func AddNode(ctx context.Context, name string, rdb *redis.Client, opts ...NodeOp
workerTTL: o.workerTTL,
workerShutdownTTL: o.workerShutdownTTL,
pendingJobTTL: o.pendingJobTTL,
logger: logger.WithPrefix("pool", name, "node", nodeID),
h: jumpHash{crc64.New(crc64.MakeTable(crc64.ECMA))},
stop: make(chan struct{}),
rdb: rdb,
logger: logger,
}

nch := nodeReader.Subscribe()
Expand Down