import { Node } from "@counterfactual/types" ; import { Controller } from "rpc-server" ; import { RequestHandler } from "../request-handler" ; export abstract class NodeController extends Controller { public static readonly methodName : Node . MethodName ; public async executeMethod ( requestHandler , params ) { await this . beforeExecution ( requestHandler , params ) ; const lockNames = await this . getRequiredLockNames ( requestHandler , params ) ; const createExecutionPromise = ( ) => this . executeMethodImplementation ( requestHandler , params ) ; const ret = await requestHandler . processQueue . addTask ( lockNames , createExecutionPromise ) ; await this . afterExecution ( requestHandler , params ) ; return ret ; } protected abstract executeMethodImplementation ( requestHandler , params ) ; protected async beforeExecution ( requestHandler , params ) { } protected async afterExecution ( requestHandler , params ) { } protected async getRequiredLockNames ( requestHandler , params ) { return [ ] ; } }