-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Leverage local rate limiting if available in environment
- Loading branch information
1 parent
de36130
commit c354c30
Showing
13 changed files
with
538 additions
and
17 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
Binary file added
BIN
+1.58 MB
analyze/wasm/rate-limit/arcjet_analyze_bindings_rate_limit.component.core.wasm
Binary file not shown.
Binary file added
BIN
+256 Bytes
analyze/wasm/rate-limit/arcjet_analyze_bindings_rate_limit.component.core2.wasm
Binary file not shown.
Binary file added
BIN
+142 Bytes
analyze/wasm/rate-limit/arcjet_analyze_bindings_rate_limit.component.core3.wasm
Binary file not shown.
37 changes: 37 additions & 0 deletions
37
analyze/wasm/rate-limit/arcjet_analyze_bindings_rate_limit.component.d.ts
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ArcjetRateLimitStorage } from './interfaces/arcjet-rate-limit-storage.js'; | ||
import { ArcjetRateLimitTime } from './interfaces/arcjet-rate-limit-time.js'; | ||
export interface ImportObject { | ||
'arcjet:rate-limit/storage': typeof ArcjetRateLimitStorage, | ||
'arcjet:rate-limit/time': typeof ArcjetRateLimitTime, | ||
} | ||
export interface Root { | ||
tokenBucket(config: string, request: string): string, | ||
fixedWindow(config: string, request: string): string, | ||
slidingWindow(config: string, request: string): string, | ||
} | ||
|
||
/** | ||
* Instantiates this component with the provided imports and | ||
* returns a map of all the exports of the component. | ||
* | ||
* This function is intended to be similar to the | ||
* `WebAssembly.instantiate` function. The second `imports` | ||
* argument is the "import object" for wasm, except here it | ||
* uses component-model-layer types instead of core wasm | ||
* integers/numbers/etc. | ||
* | ||
* The first argument to this function, `getCoreModule`, is | ||
* used to compile core wasm modules within the component. | ||
* Components are composed of core wasm modules and this callback | ||
* will be invoked per core wasm module. The caller of this | ||
* function is responsible for reading the core wasm module | ||
* identified by `path` and returning its compiled | ||
* `WebAssembly.Module` object. This would use `compileStreaming` | ||
* on the web, for example. | ||
*/ | ||
export function instantiate( | ||
getCoreModule: (path: string) => Promise<WebAssembly.Module>, | ||
imports: ImportObject, | ||
instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance> | ||
): Promise<Root>; | ||
|
Oops, something went wrong.