import { v4 as uuidv4 } from 'uuid';

export abstract class Payload {
    protected msgId: string;
    protected msgTye: string;
    body: PayloadBody;
    constructor(body?: PayloadBody) {
        this.msgId = uuidv4().replace(/-/g, '')
        this.msgTye = 'kt_ec'
        this.body = body;
    }
    abstract getTopic(): string
    abstract getVersion(): number
    getMsgId(): string {
        return this.msgId
    }
}

export interface PayloadBody {
}

export interface IPublisher {
    publishToMaster(payload: Payload)
    publishToSlave(payload: Payload)
}

export interface IConsumer {
    consume(payload: Payload, baseEventHandler: BaseEventHandler)
}

export interface BaseEventHandler {
    handle(msg: any)
}


