mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
26 lines
611 B
Go
26 lines
611 B
Go
package delayqueue
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"log/slog"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/redis/go-redis/v9"
|
||
|
|
|
||
|
|
"github.com/chaitin/MonkeyCode/backend/domain"
|
||
|
|
)
|
||
|
|
|
||
|
|
// VMExpireQueue VM 过期队列
|
||
|
|
type VMExpireQueue struct {
|
||
|
|
*RedisDelayQueue[*domain.VmExpireInfo]
|
||
|
|
}
|
||
|
|
|
||
|
|
// NewVMExpireQueue 创建 VM 过期队列
|
||
|
|
func NewVMExpireQueue(redis *redis.Client, logger *slog.Logger) *VMExpireQueue {
|
||
|
|
queue := NewRedisDelayQueue(
|
||
|
|
redis, logger,
|
||
|
|
WithPrefix[*domain.VmExpireInfo]("mcai:vmexpire"),
|
||
|
|
WithRequeueDelay[*domain.VmExpireInfo](1*time.Minute),
|
||
|
|
WithPollInterval[*domain.VmExpireInfo](5*time.Second),
|
||
|
|
)
|
||
|
|
return &VMExpireQueue{queue}
|
||
|
|
}
|