Giter Club home page Giter Club logo

Comments (5)

benmanns avatar benmanns commented on July 24, 2024 3

Currently, there's no way to access the JSON payload except through the args interface.

I am investigating a way to specify the type of object you want for a worker function. Possibly something along the lines of:

goworker.RegisterType("MyClass", myFunc, &MyType{})

where you would only do one type assertion within myFunc for args.(MyType).

Alternatively, we could use json.RawMessage and have the function do the unmarshalling, but this, too, would require some reworking. Possibly something along the lines of:

goworker.RegisterRaw("MyClass", myFunc)

then within the worker

var val MyType
json.Unmarshal(raw, val)

What would work better for you?

from goworker.

akshayrawat avatar akshayrawat commented on July 24, 2024 1

I suppose the RegisterRaw approach is a little more flexible (and relevant to my use-case). I have a nested map of arrays of maps. I was just thinking about using something like go-simplejson to unmarshal it, if access to raw JSON was there.

from goworker.

wricardo avatar wricardo commented on July 24, 2024 1

+1 for RegisterRaw

from goworker.

rjrobinson avatar rjrobinson commented on July 24, 2024

👍 As well. I think this will help with a lot of bigger payloads complex payloads.

My workaround was actually to just save a temp .json file, and have the goworker trigger a download from s3, and unmarshal it into a struct. Though hacky, cut down time on building lots of workers.

from goworker.

snobb avatar snobb commented on July 24, 2024

👍 on RegisterRaw. My workaround was to Marshal the payload back and then Unmarshal to my the actual struct, which is quite wasteful.

from goworker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.