Skip to content

Instantly share code, notes, and snippets.

func newEventCreatedTask(ctx context.Context, s domain.Event) (*asynq.Task, error) {
payload := map[string]interface{}{"event_id": s.ID, "payload": string(s.Payload)} // some type for payload
task, err := domain.NewTask(ctx, payload)
if err != nil {
log.Error("unable to create new task: %s", err.Error())
return nil, err
}
// transform to raw data
data, err := json.Marshal(*task)
@mrsufgi
mrsufgi / gist:842b1dafed63745e14e2876e41f5eeb4
Created November 26, 2018 09:26
proxy implementation example
/*
Hey All! Most devs (including me) uses Proxy and Decorators on a daily basis but doesn't know to implement or use one. I wanted to show two snippets me and @Nicolas Mendzylewski wrote that might be useful in the future:
const withOBAPIAuth = function withOBAPIAuthenticationToken(proto) {
const handler = {
get(target, propKey) {