forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Event bus to streamline process up (serverless-dns#43)
* Event bus to streamline process up Since nodejs doesn't respect import sequence (unlike deno), conditionals are required to initialize global deps like log, env, plugin.services etc. This is solved with a pub-sub mechanism where-in modules subscribe to events to know when their deps are up and running. Today, the "config" module, imported for side-effects from the entrypoints (server-workers.js for workers, server-deno.ts for deno, and server-node.js for node) of respective runtimes, initializes "log" and "env" objs, and kicks-off other basic setup. It then publishes a "ready" event which triggers the "plugin" module, that then inits essential "services", which includes downloading the blocklists where a disk is available (like on fly / dev machines). Once the service init is done, "plugin" publishes a "go" event. The entrypoints listening on the "go" event now bring up their endpoints as required and start serving DoH/DoT requests. pub/sub could have been a state-machine, but it isn't. All subs run as micro-tasks on all runtimes. To account for time delay between blocklist download (during service init) and entrypoint bring up (in response to "go" event), fly's grace-period for health-checks is increased to 15s. In TypeScript, the Window global object is extended to include "log" and "env" global properties. This Window is aliased to globalThis in JavaScript files. Even though globalThis support was added in TypeScript v3.4, there seems to be no way to extend globalThis, per se. Co-authored-by: Amith Mohanan <[email protected]>
- Loading branch information
1 parent
147b56e
commit 95dfdb4
Showing
33 changed files
with
1,181 additions
and
787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ dist/ | |
node_modules/ | ||
worker/ | ||
test/data/cache/ | ||
blocklists__/ | ||
|
||
package-lock.json | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.