import { EventEmitter } from "events" ; import { IContext , IQueuedMessage , ILogger , IContextErrorData } from "@fluidframework/server-services-core" ; import { CheckpointManager } from "./checkpointManager" ; export class Context extends EventEmitter implements IContext { private closed = false ; constructor ( private readonly checkpointManager , public readonly log ) { super ( ) ; } /**
     * Updates the checkpoint for the partition
     */ public checkpoint ( queuedMessage ) { if ( this . closed ) { return ; } this . checkpointManager . checkpoint ( queuedMessage ) . catch ( ( error ) => { if ( this . closed ) { return ; } this . error ( error , { restart : true } ) ; } ) ; } param error param errorData public error ( error , errorData ) { this . emit ( "error" , error , errorData ) ; } /**
     * Closes the context
     */ public close ( ) { this . closed = true ; this . removeAllListeners ( ) ; } }