Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLTCONN-4268: Support patching connector configs #48

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface Response<T> {
send(output: T): void
saveState(state: any): void
keepAlive(): void
patchConfig(patches: Patch[]): void
}

/**
Expand Down Expand Up @@ -47,6 +48,10 @@ export class ResponseStream<T> implements Response<T> {
keepAlive(): void {
this._writable.write(new RawResponse({}, ResponseType.KeepAlive))
}

patchConfig(patches: Patch[]): void {
this._writable.write(new RawResponse(patches, ResponseType.Config))
}
}

/**
Expand All @@ -55,7 +60,8 @@ export class ResponseStream<T> implements Response<T> {
export enum ResponseType {
Output = 'output',
State = 'state',
KeepAlive = 'keepAlive'
KeepAlive = 'keepAlive',
Config = 'config'
}

/**
Expand All @@ -70,3 +76,17 @@ export class RawResponse {
this.type = type
}
}

/**
* Enum PatchOp is the config patch operations
*/
export enum PatchOp {
Add = 'add',
Replace = 'replace',
Remove = 'remove'
}

/**
* Patch is a JSON patch for source config
*/
export type Patch = { op: PatchOp, path: string, value?: any }
Loading