Skip to content

Commit

Permalink
fix: generic issue and moved destroy before handle
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed May 24, 2023
1 parent 420ddc9 commit 03b03e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dataloader_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *RedisDataloader[P]) BuryFor(ctx context.Context, payload P, forTimeRang
//
// ZADD sortedSetKey utilUnixMilliTimestamp <capsule base64 string>
func (r *RedisDataloader[P]) BuryUtil(ctx context.Context, payload P, utilUnixMilliTimestamp int64) error {
newCapsule := TimeCapsule[any]{Payload: payload}
newCapsule := TimeCapsule[P]{Payload: payload}
return r.bury(ctx, newCapsule.Base64String(), utilUnixMilliTimestamp)
}

Expand Down
2 changes: 1 addition & 1 deletion dataloader_rueidis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *RueidisDataloader[P]) BuryFor(ctx context.Context, payload P, forTimeRa
//
// ZADD sortedSetKey utilUnixMilliTimestamp <capsule base64 string>
func (r *RueidisDataloader[P]) BuryUtil(ctx context.Context, payload P, utilUnixMilliTimestamp int64) error {
newCapsule := TimeCapsule[any]{Payload: payload}
newCapsule := TimeCapsule[P]{Payload: payload}
return r.bury(ctx, newCapsule.Base64String(), utilUnixMilliTimestamp)
}

Expand Down
8 changes: 3 additions & 5 deletions timecapsule.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ func (t *TimeCapsuleDigger[P]) Start() {

t.logger.Debugf("[TimeCapsule] dug a new capsule from dataloader %v", t.dataloader.Type())

assertedCapsule, ok := any(dugCapsule).(*TimeCapsule[P])
if ok && t.handlerFunc != nil && assertedCapsule != nil {
t.handlerFunc(t, assertedCapsule)
}

t.destroy(dugCapsule)
if t.handlerFunc != nil {
t.handlerFunc(t, dugCapsule)
}
case <-ctx.Done():
return
default:
Expand Down

0 comments on commit 03b03e4

Please sign in to comment.