30 lines
597 B
Go
30 lines
597 B
Go
package queue
|
|
|
|
import (
|
|
"context"
|
|
|
|
"app-deploy-platform/backend/internal/config"
|
|
)
|
|
|
|
type Job struct {
|
|
Kind string `json:"kind"`
|
|
DeploymentID uint `json:"deployment_id"`
|
|
BuildID uint `json:"build_id"`
|
|
ReleaseRunID uint `json:"release_run_id"`
|
|
}
|
|
|
|
type Handler func(context.Context, Job) error
|
|
|
|
type JobQueue interface {
|
|
Publish(context.Context, Job) error
|
|
StartConsumer(context.Context, Handler) error
|
|
Close() error
|
|
}
|
|
|
|
func New(cfg config.Config) (JobQueue, error) {
|
|
if cfg.Queue.Driver == "memory" {
|
|
return NewMemoryQueue(128), nil
|
|
}
|
|
return NewRocketMQQueue(cfg)
|
|
}
|