Skip to content

Conversation

@kinyoklion
Copy link
Member

The primary goal of this PR was to add the platform interfaces as well as an initial implementation.

In doing so I actually started using the other interfaces, so I needed to setup a structure to export them. So a good amount of code shows as changed from things being re-arranged.

ignorePatterns: ["**/dist/**"],
rules: {
},
ignorePatterns: ["**/dist/**"],
Copy link
Member Author

Choose a reason for hiding this comment

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

This was duplicated.

@@ -0,0 +1,6 @@
module.exports = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Because we use typescript jest needs a config file to understand how to compile things.

@@ -0,0 +1,120 @@
import * as http from 'http';
Copy link
Member Author

Choose a reason for hiding this comment

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

This covers the basics of requests. I will see about a standalone TLS and Proxy test later.

"version": "1.0.0",
"description": "Node platform for the JS Server SDK",
"type": "commonjs",
"main": "./dist/index.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

There are some changes to structure to allow package.json to be imported. The typescript compiler doesn't like things outside the rootdir.

@@ -0,0 +1,15 @@
/* eslint-disable class-methods-use-this */
Copy link
Member Author

Choose a reason for hiding this comment

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

Crypto and Filesystem are just pass through implementations of the node versions of these methods.

@@ -0,0 +1,102 @@
// import { Options, platform, options } from '@launchdarkly/js-server-sdk-common';
import createHttpsProxyAgent, { HttpsProxyAgentOptions } from 'https-proxy-agent';
Copy link
Member Author

Choose a reason for hiding this comment

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

This package does not look abandoned. Unlike tunnel which we were using. It should provide the same functionality. I need to add some testing for it later.

return {
ca: tlsOptions.ca,
cert: tlsOptions.cert,
checkServerIdentity: tlsOptions.checkServerIdentity,
Copy link
Member Author

Choose a reason for hiding this comment

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

This checkServerIdentity function does not look to have been implemented correctly in the node server SDK before. The issue was it was being passed as a request parameter. All the other TLS parameters can be passed in a request, but this is not part of that interface. I did some testing to validate that it does not get called when used like that.

It does work correctly when incorporated into an agent.

That creates overlap between the proxy and TLS, both of which are agents. Thankfully node-https-proxy forwards additional configuration to the underlying agent so we can easily combine the two.

/**
* @inheritdoc
*/
fetch(url: string, options: platform.Options = {}): Promise<platform.Response> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to go with a fetch interface here because it should be more portable in the long-run. It is available in the various web worker and wasm environments. Additionally node is adding its own fetch support eventually.

@@ -1,3 +1,24 @@
import doesItWork from '@launchdarkly/js-server-sdk-common';
/* eslint-disable no-console */
Copy link
Member Author

Choose a reason for hiding this comment

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

This file contains temporary code at the moment. A convenient place to try things.

@kinyoklion kinyoklion marked this pull request as ready for review May 18, 2022 20:44

/**
* Allows you to specify a host for an optional HTTP proxy.
* Allows you to specify configuration for an optional HTTP proxy.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a breaking change. So I could consider introducing these at the top level again and then doing some config work to put them into an object. This does seem like a cleaner way to expose them in the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could release a transitional minor version where both are supported but the top-level ones are deprecated.

@kinyoklion kinyoklion requested a review from eli-darkly May 18, 2022 20:46
Copy link
Contributor

@eli-darkly eli-darkly left a comment

Choose a reason for hiding this comment

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

Looks very clear and sensible.

@kinyoklion kinyoklion changed the title Add platform interfaces and initial implementation. [sc-151494] Add platform interfaces and initial implementation. May 19, 2022
Co-authored-by: Eli Bishop <eli@launchdarkly.com>
@kinyoklion kinyoklion merged commit bc1688e into main May 19, 2022
@kinyoklion kinyoklion deleted the rlamb/platform-interfaces branch May 19, 2022 15:50
kinyoklion added a commit that referenced this pull request Jun 1, 2022
Co-authored-by: Alex Engelberg <alex.benjamin.engelberg@gmail.com>
Co-authored-by: Matthew M. Keeler <keelerm84@gmail.com>
kinyoklion added a commit that referenced this pull request Jun 2, 2022
kinyoklion added a commit that referenced this pull request Jul 5, 2022
…through. (#14)

* Add bucketing and common tests.

* Correct spelling.

* Check numeric conversion step.

* Add operators and tests.

* Add unrecognized operator test.

* Add interfaces for the data we use during evaluations. Start scaffolding evaluator.

* Cleanup

* Add target evaluation.

* Add documentation and tests.

* Linting.

* Add parsers and update evaluation types.

* Add TODO comment and lint.

* Add internal specifiers.

* Improve implementation and add tests.

* Comment updates.

* Helps if you save.

* Add prerequisite evaluations.

* Refine prerequisite code.

* Progress on rule evaluation.

* Implement rules and fallthrough.

* Add clause tests and fix bugs.

* Add rules tests.

* Remove TODO that is no longer needed.

* Rename static methods to lowercase.

* Rename matchClause.
kinyoklion added a commit that referenced this pull request Aug 23, 2022
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.

3 participants