package zqueue import ( "errors" "fmt" "github.com/gin-gonic/gin" "github.com:barsukov-vv/komrad/zgin" "sync" ) type ZQueue struct { queue map[string]chan *ZJob mu sync.Mutex } type ZJob struct { Id int64 `json:"id"` Body any `json:"body"` Result chan any `json:"-"` Wg *sync.WaitGroup `json:"-"` } func New() *ZQueue { return &ZQueue{} } func Default() *ZQueue { return &ZQueue{} } func (q *ZQueue) GetHandler(c *gin.Context) { queue := c.Param("queue") if qChan, ok := q.queue[queue]; !ok { zgin.Err(c, errors.New(fmt.Sprintf("unknown queue: '%s'", queue))) } else { job := <-qChan zgin.Ok(c, job.Body) return } } func (q *ZQueue) PostHandler(c *gin.Context) { } func (q *ZQueue) NewHandler(c *gin.Context) { }