Class: TestService
TestService API defines an interface supported only by the Temporal Test Server. It provides functionality needed or supported for testing purposes only.
This is an EXPERIMENTAL API.
Extends
Service
Properties
getCurrentTime
getCurrentTime:
GetCurrentTime
GetCurrentTime returns the current Temporal Test Server time
This time might not be equal to System#currentTimeMillis() due to time skipping.
lockTimeSkipping
lockTimeSkipping:
LockTimeSkipping
LockTimeSkipping increments Time Locking Counter by one.
If Time Locking Counter is positive, time skipping is locked (disabled). When time skipping is disabled, the time in test server is moving normally, with a real time pace. Test Server is typically started with locked time skipping and Time Locking Counter = 1.
LockTimeSkipping and UnlockTimeSkipping calls are counted.
requestDelimited
requestDelimited:
boolean
Whether requests are length-delimited.
Inherited from
$protobuf.rpc.Service.requestDelimited
responseDelimited
responseDelimited:
boolean
Whether responses are length-delimited.
Inherited from
$protobuf.rpc.Service.responseDelimited
rpcImpl
rpcImpl:
RPCImpl|null
RPC implementation. Becomes null once the service is ended.
Inherited from
$protobuf.rpc.Service.rpcImpl
sleep
sleep:
Sleep
This call returns only when the Test Server Time advances by the specified duration. This is an EXPERIMENTAL API.
sleepUntil
sleepUntil:
SleepUntil
This call returns only when the Test Server Time advances to the specified timestamp. If the current Test Server Time is beyond the specified timestamp, returns immediately. This is an EXPERIMENTAL API.
unlockTimeSkipping
unlockTimeSkipping:
UnlockTimeSkipping
UnlockTimeSkipping decrements Time Locking Counter by one.
If the counter reaches 0, it unlocks time skipping and fast forwards time. LockTimeSkipping and UnlockTimeSkipping calls are counted. Calling UnlockTimeSkipping does not guarantee that time is going to be fast forwarded as another lock can be holding it.
Time Locking Counter can't be negative, unbalanced calls to UnlockTimeSkipping will lead to rpc call failure
unlockTimeSkippingWithSleep
unlockTimeSkippingWithSleep:
UnlockTimeSkippingWithSleep
UnlockTimeSkippingWhileSleep decreases time locking counter by one and increases it back once the Test Server Time advances by the duration specified in the request.
This call returns only when the Test Server Time advances by the specified duration.
If it is called when Time Locking Counter is
- more than 1 and no other unlocks are coming in, rpc call will block for the specified duration, time will not be fast forwarded.
- 1, it will lead to fast forwarding of the time by the duration specified in the request and quick return of this rpc call.
- 0 will lead to rpc call failure same way as an unbalanced UnlockTimeSkipping.
Methods
emit()
emit(
evt, ...args):this
Emits an event by calling its listeners with the specified arguments.
Parameters
evt
string
Event name
args
...any[]
Arguments
Returns
this
this
Inherited from
$protobuf.rpc.Service.emit
end()
end(
endedByRPC?):Service
Ends this service and emits the end event.
Parameters
endedByRPC?
boolean
Whether the service has been ended by the RPC implementation.
Returns
Service
this
Inherited from
$protobuf.rpc.Service.end
off()
off(
evt?,fn?):this
Removes an event listener or any matching listeners if arguments are omitted.
Parameters
evt?
string
Event name. Removes all listeners if omitted.
fn?
EventEmitterListener
Listener to remove. Removes all listeners of evt if omitted.
Returns
this
this
Inherited from
$protobuf.rpc.Service.off
on()
on(
evt,fn,ctx?):this
Registers an event listener.
Parameters
evt
string
Event name
fn
EventEmitterListener
Listener
ctx?
any
Listener context
Returns
this
this
Inherited from
$protobuf.rpc.Service.on
rpcCall()
rpcCall<
TReq,TRes>(method,requestCtor,responseCtor,request,callback):void
Calls a service method through rpcImpl.
Type Parameters
TReq
TReq extends Message<TReq>
TRes
TRes extends Message<TRes>
Parameters
method
Method | ServiceMethod<TReq, TRes>
Reflected or static method
requestCtor
Constructor<TReq>
Request constructor
responseCtor
Constructor<TRes>
Response constructor
request
TReq | Properties<TReq>
Request message or plain object
callback
ServiceMethodCallback<TRes>
Service callback
Returns
void
Inherited from
$protobuf.rpc.Service.rpcCall
create()
staticcreate(rpcImpl,requestDelimited?,responseDelimited?):TestService
Creates new TestService service using the specified rpc implementation.
Parameters
rpcImpl
RPCImpl
RPC implementation
requestDelimited?
boolean
Whether requests are length-delimited
responseDelimited?
boolean
Whether responses are length-delimited
Returns
TestService
RPC service. Useful where requests and/or responses are streamed.