com.r3corda.node.services.events / NodeSchedulerService

# NodeSchedulerService

`class NodeSchedulerService : SchedulerService, SingletonSerializeAsToken`

A first pass of a simple SchedulerService that works with MutableClocks for testing, demonstrations and simulations that also encompasses the Wallet observer for processing transactions.

This will observe transactions as they are stored and schedule and unschedule activities based on the States consumed or produced.

TODO: Needs extensive support from persistence and protocol frameworks to be truly reliable and atomic.

Currently does not provide any system state other than the ContractState so the expectation is that a transaction is the outcome of the activity in order to schedule another activity. Once we have implemented more persistence in the nodes, maybe we can consider multiple activities and whether the activities have been completed or not, but that starts to sound a lot like off-ledger state.

### Parameters

`services` - Core node services.
`protocolLogicRefFactory` - Factory for restoring ProtocolLogic instances from references.
`schedulerTimerExecutor` - The executor the scheduler blocks on waiting for the clock to advance to the next activity. Only replace this for unit testing purposes. This is not the executor the ProtocolLogic is launched on.

### Constructors

<init> | `NodeSchedulerService(services: ServiceHubInternal, protocolLogicRefFactory: ProtocolLogicRefFactory = ProtocolLogicRefFactory(), schedulerTimerExecutor: Executor = Executors.newSingleThreadExecutor())` A first pass of a simple SchedulerService that works with MutableClocks for testing, demonstrations and simulations that also encompasses the Wallet observer for processing transactions.

### Functions

scheduleStateActivity | `fun scheduleStateActivity(action: ScheduledStateRef): Unit` Schedule a new activity for a TX output, probably because it was just produced.
unscheduleStateActivity | `fun unscheduleStateActivity(ref: StateRef): Unit` Unschedule all activity for a TX output, probably because it was consumed.

### Inherited Functions

toToken | `open fun toToken(context: SerializeAsTokenContext): SerializationToken`