4 ms·
How would you specify a job with multiple parameters? You use "ping" as the example. If I wanted to run "ping -c 20 10.10.10.10", how would I accomplish that?
by chrishacken 10y ago
How would you specify a job with multiple parameters? You use "ping" as the example. If I wanted to run "ping -c 20 10.10.10.10", how would I accomplish that? It's not immediately obvious if that is possible.
From going through the source, it looks like the payload is the cmd. Can those be multiple words or will it read each word as a separate argument.
handler := s.Router.Handler(cmd.Name)
reply, err := handler.Exec(cmd)
- iamduo 10y agoA job in Workq doesn't directly target a system command or anything. The short answer is a job could be thought of as a function call. The name of the job is the function, and the job's payload is its parameters. This allows a worker to connect to Workq and pick up available jobs enqueued previously by a client. It is up to the worker to decipher the payload and act on it, which may be run “ping 10.10.10.10” on the worker node. The ping example was just given so I could enqueue a job named “ping” as a client and respond with a “pong” text result from a worker. Just a silly example :). Real use cases would be background jobs such as sending emails, http downloads, image resizing…etc.
- noselasd 10y agoThis is more or less a message queue, one side (client) sends a message, the other side (worker) receive and act on it. But structured around the common use case of someone submitting a "job" to be performed(whenever possible, or at a certain time) and workers picking up and performing the job, reporting back the outcome. "ping" here is just a message, not the name of a system command/executable - in this case the worker receives the "ping" request, and just replies with a "pong" message - both sides are code you need to write. You can encode whatever you want in the payload, json, simple plaintext - it's up to the client and the worker to agree on the meaning.
- chrishacken 10y agoThank you, that clears up my confusion.