%SYSTEM.ShardWorkMgrhidden class %SYSTEM.ShardWorkMgr
Internal class to manage distributing work to other systems in a sharded environment.
This is modelled on the
Add a task to the Work Queue Manager runqueue on a remote machine. You get a %Status if the work was queued correctly. remoteSystem the namespace or implied reference that maps to the remote systems IRISLOCALDATA database so you can form a valid global reference with '^|remoteSystem|IRIS.WorkQueue' that will write data to the target system. The remote work is run in the namespace with the same name as the current namespace when you create the work group. You pass the entry point to call in 'work' argument. This can be either '##class(Classname).ClassMethod' or '$$entry^rtn' and it is expected to return a %Status code on completion. If you want to call a function that does not return any value on completion then prepend the class syntax with '=' such as '=##class(Classname).ClassMethod' or for calling a function do not include the '$$' for example 'entry^rtn'. The item being called may also throw exceptions in order to indicate an error happened which is trapped and converted to a %Status value to be returned in the master process. You can also pass additional arguments including arrays by reference. Note that the size of the data passed in these arguments should be kept relatively small, if there is a large amount of information that needs to be passed then put this in a global. The security context of the caller is also recorded when this function is called so it can be used when the work is executed.
Queueexcept you can also pass in a 'callback' which is a function or class method that is called in the master process when this unit of work is complete. This function is called with the same arguments the original 'work' is called with so it knows which unit of work is complete. Also the callback function can access the '%job' public variable which is the $job of the process which really did the work, the '%status' public variable which is the %Status return code from the work unit this is the callback for and '%workqueue' public variable which is the oref of the work queue instance. If using the Waitto wait for the work to be completed the callback can signal that it should return to the caller rather than waiting for more events by setting the public variable '%exit' to 1.