Skip to content

Commit

Permalink
Use the context interface rather than struct (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
lackstein authored Feb 7, 2024
1 parent 5eb2e6d commit 3fea682
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions batch/middlware.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func (b *BatchSubsystem) pushMiddleware(ctx context.Context, next func() error) error {
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Ctx)
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Context)

if bid, ok := mh.Job().GetCustom("bid"); ok {
batchId, err := b.batchManager.getBatchIdFromInterface(bid)
Expand All @@ -33,7 +33,7 @@ func (b *BatchSubsystem) pushMiddleware(ctx context.Context, next func() error)

func (b *BatchSubsystem) handleJobFinished(success bool) func(ctx context.Context, next func() error) error {
return func(ctx context.Context, next func() error) error {
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Ctx)
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Context)

if success {
// check if this is a success / complete job from batch
Expand Down
4 changes: 2 additions & 2 deletions uniq/uniq.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (u *UniqSubsystem) addMiddleware() {
}

func (u *UniqSubsystem) lockMiddleware(ctx context.Context, next func() error) error {
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Ctx)
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Context)

var uniqueFor float64
uniqueForValue, ok := mh.Job().GetCustom("unique_for")
Expand Down Expand Up @@ -129,7 +129,7 @@ func (u *UniqSubsystem) lockMiddleware(ctx context.Context, next func() error) e

func (u *UniqSubsystem) releaseLockMiddleware(releaseAt string) func(context.Context, func() error) error {
return func(ctx context.Context, next func() error) error {
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Ctx)
mh := ctx.Value(manager.MiddlewareHelperKey).(manager.Context)

if _, ok := mh.Job().GetCustom("unique_for"); !ok {
return next()
Expand Down

0 comments on commit 3fea682

Please sign in to comment.