package taskqueue

import (
	"context"
)

type taskCtxKeyTp string

const (
	taskCtxKey taskCtxKeyTp = "task_context_key"
)

func InjectTaskIntoCtx(ctx context.Context, task *Task) context.Context {
	return context.WithValue(ctx, taskCtxKey, task)
}

func GetTaskFromContext(ctx context.Context) (*Task, bool) {
	val := ctx.Value(taskCtxKey)
	task, ok := val.(*Task)
	if ok {
		return task, true
	} else {
		return nil, false
	}
}
