Written by

Question Rubens Silva · Jul 12, 2017

Cannot call job for instance method?

Greetings, can someone give me some help? I'm trying to use job for a instance method, as it's described here but...
Anyway, I have a method like this:

Method PrepareInstance(path){set ..Tool = ##class(Tool).%New(path)do $System.Event.Signal($zparent)}

That is being called like this:

Method TestPurge() As %Status{job ..PrepareInstance(..GetTestDirectory("../fixtures/_/dummy-project"))::10set msg = $System.Event.Wait("",10)
}

But it fails because:

<METHOD DOES NOT EXIST>zTestPurge+1^UnitTest.Tool.1 *PrepareInstance

Am I missing something or is that a bug? The method surely exists and the job is also being created inside another instance method.

Thanks in advance.

Comments

Eduard Lebedyuk · Jul 12, 2017

Only class methods can be used for jobs, otherwise where does the object belong - to a parent or child process?

0
Rubens Silva  Jul 12, 2017 to Eduard Lebedyuk

What about this? 

0
Herman Slagman  Jul 12, 2017 to Rubens Silva

..Method can be a instance method as well as a class method within the context of an instance, that's the syntax.

An instance method needs the instance (object) it belongs to, if you would like to 'job' that to another process, then in some way the object would need go go along with that (aka Beam Me Up Scotty ;-)) and that's not supported by Cache'.

If you have an instance method in your class that doesn't need the instance, you probably want to change that to a class method.

0
Eduard Lebedyuk  Jul 12, 2017 to Rubens Silva

What about it?

It says that class methods can be jobbed as ..Method() instead of ##class(Package.Class).Method(), if we're in a class context.

0
Rubens Silva · Jul 12, 2017

"The following example uses relative dot syntax (..) to refer to a method of the current object."
If so, it's pretty misleading. But I accept your answer and will mark it as well.

0