Skip to content

Add content encoding to server options - #1250

Closed
Vinicius Stock (vinistock) wants to merge 2 commits into
microsoft:mainfrom
vinistock:vs/add_content_encoding_server_options
Closed

Vinicius Stock (vinistock) wants to merge 2 commits into
microsoft:mainfrom
vinistock:vs/add_content_encoding_server_options

Conversation

@vinistock

Copy link
Copy Markdown
Contributor

For more context, see #553.

This PR adds allows clients to define contentEncoder and contentDecoder in their server options. This addition makes it easier for clients to opt-in to different content encodings, such as msgpack, without having to worry about the life cycle of the process spawned - which is necessary when passing a function.

There's a simple example usage in the integration tests, which doesn't actually do anything, but demonstrates that clients will be able to hook their own content encoders and decoders.

Comment thread client/src/node/main.ts

export type ServerOptions = Executable | { run: Executable; debug: Executable } | { run: NodeModule; debug: NodeModule } | NodeModule | (() => Promise<ChildProcess | StreamInfo | MessageTransports | ChildProcessInfo>);
type ContentEncoding = { contentEncoder?: ContentEncoder; contentDecoder?: ContentDecoder };
export type ServerOptions = Executable & ContentEncoding | { run: Executable; debug: Executable } & ContentEncoding | { run: NodeModule; debug: NodeModule } & ContentEncoding | NodeModule & ContentEncoding | (() => Promise<ChildProcess | StreamInfo | MessageTransports | ChildProcessInfo>);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather extend the original interfaces / types than & types here. We should also think about the effort it would take to make this type safe since encoders / decoders can't be supported on all transport kind. At least we have to issue a warning to inform the user about it.

Side note: regardless of what we do we should think about whether we want to apply the same for the Executable setup since Node IPC doesn't make too much sense there either.

@dbaeumer

Copy link
Copy Markdown
Member

I will close the PR for now. Please ping if you decide to continue working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants