Skip to content

feat: add Function (FunctionRegistry) client#1618

Merged
eaddingtonwhite merged 7 commits into
mainfrom
feat/function-client
Jun 18, 2026
Merged

feat: add Function (FunctionRegistry) client#1618
eaddingtonwhite merged 7 commits into
mainfrom
feat/function-client

Conversation

@eaddingtonwhite

Copy link
Copy Markdown
Member

Adds a PreviewFunctionClient for managing Momento Functions, mirroring PreviewLeaderboardClient (a preview, data-plane client on the cache endpoint).

const fns = new PreviewFunctionClient({credentialProvider});
await fns.putFunction(cacheName, name, wasmBytes, {description, environmentVariables}); // -> PutFunction.Success.functionId()
await fns.listFunctions(cacheName);            // -> ListFunctions.Success.getFunctions(): FunctionInfo[]
await fns.listFunctionVersions(functionId);    // -> ListFunctionVersions.Success.getVersions(): FunctionVersionInfo[]
await fns.deleteFunction(cacheName, name);

Requires @gomomento/generated-types 0.133.0 — the first release that includes the FunctionRegistry service (added in momentohq/client-protos#340).

Notes / decisions worth a look:

  • nodejs only for now — no web parity yet. The immediate consumer is a Node/Lambda CDK construct; happy to follow up with a client-sdk-web implementation if we want parity before release.
  • listFunctions/listFunctionVersions are server-streaming; they use streaming interceptors without the retry interceptor. putFunction/deleteFunction aren't in the retry allowlist, so mutations are never auto-retried.
  • deleteFunction on a missing function returns Error (NOT_FOUND), like deleteCache — not idempotent.
  • putFunction sends a 32 MB max-message override (wasm ships inline) and uses a 60s deadline.
  • Integration test (test/integration/function/) runs in the normal sweep when MOMENTO_API_KEY is set, via CredentialProvider.fromEnvVarV2(). It puts/lists/deletes a real function using a small committed wasm-component fixture.

Tested: unit tests for construction + validation; a live integration test against the alpha cell (put → list → listFunctionVersions → delete) passes.

Opening as a draft to get feedback on the web-parity question and the design notes above before finalizing.

Adds PreviewFunctionClient for managing Momento Functions (putFunction,
deleteFunction, listFunctions, listFunctionVersions), mirroring
PreviewLeaderboardClient (a preview, data-plane client on the cache endpoint).

Requires @gomomento/generated-types 0.133.0, the first release that includes
the FunctionRegistry service. nodejs only for now (no web parity yet).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new preview, Node.js-only client for managing Momento Functions via the new FunctionRegistry data-plane service on the cache endpoint, along with the corresponding core response types and metadata models.

Changes:

  • Introduces core Function response types/enums and FunctionInfo / FunctionVersionInfo models, plus an internal IFunctionClient interface.
  • Adds PreviewFunctionClient + internal gRPC implementation (streaming list operations, 32MB message size override, Function-specific configuration defaults).
  • Adds unit + live integration tests and bumps @gomomento/generated-types to 0.133.0.

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/messages/responses/function/put-function.ts Adds PutFunction response types (Success/Error).
packages/core/src/messages/responses/function/list-functions.ts Adds ListFunctions response types (Success/Error) returning FunctionInfo[].
packages/core/src/messages/responses/function/list-function-versions.ts Adds ListFunctionVersions response types (Success/Error) returning FunctionVersionInfo[].
packages/core/src/messages/responses/function/delete-function.ts Adds DeleteFunction response types (Success/Error).
packages/core/src/messages/responses/function/index.ts Barrels Function response exports.
packages/core/src/messages/responses/enums/function/index.ts Adds enums for Function response type discrimination.
packages/core/src/messages/responses/enums/index.ts Exposes Function enums alongside existing response enums.
packages/core/src/messages/function-info.ts Adds FunctionInfo / FunctionVersionInfo metadata models used by list operations.
packages/core/src/internal/clients/function/IFunctionClient.ts Defines internal function client interface + options (PutFunctionOptions).
packages/core/src/internal/clients/function/index.ts Barrels internal function client exports.
packages/core/src/internal/clients/index.ts Exposes function client module from internal clients index.
packages/core/src/index.ts Exposes Function response types and metadata models from sdk-core entrypoint.
packages/client-sdk-nodejs/src/config/function-configuration.ts Introduces FunctionClient configuration interface + implementation.
packages/client-sdk-nodejs/src/config/function-configurations.ts Adds default “Laptop” Function configuration (60s deadline).
packages/client-sdk-nodejs/src/function-client-props.ts Adds Node SDK props type for Function client construction.
packages/client-sdk-nodejs/src/internal/function-client-all-props.ts Adds internal “all props” type for Function client instantiation.
packages/client-sdk-nodejs/src/internal/function-client.ts Implements gRPC client for FunctionRegistry (put/delete unary, list streaming).
packages/client-sdk-nodejs/src/preview-function-client.ts Adds public PreviewFunctionClient wrapper that mirrors PreviewLeaderboardClient pattern.
packages/client-sdk-nodejs/src/index.ts Re-exports Function client, configuration, and core response/model types from Node SDK entrypoint.
packages/client-sdk-nodejs/test/unit/function-client.test.ts Adds constructor + basic argument-validation unit tests.
packages/client-sdk-nodejs/test/integration/function/function-client.test.ts Adds live integration test (put → list → list versions → delete).
packages/client-sdk-nodejs/package.json Bumps generated-types dependency and adds integration-test-function script.
packages/client-sdk-nodejs/package-lock.json Locks generated-types bump to 0.133.0 with resolved tarball metadata.
Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client-sdk-nodejs/src/internal/function-client.ts
Comment thread packages/client-sdk-nodejs/src/internal/function-client.ts
Comment thread packages/client-sdk-nodejs/src/internal/function-client.ts Outdated
Addresses code review feedback: putFunction/deleteFunction now validate the
function name (and putFunction rejects empty wasm) like other resource APIs;
listFunctionVersions validates the function id; and a ListFunctionVersions row
missing id/wasm_id is now surfaced as an error instead of a degraded result.
Adds validateFunctionName/validateFunctionId to core.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

Comment thread packages/client-sdk-nodejs/src/preview-function-client.ts
Comment thread packages/client-sdk-nodejs/src/internal/function-client.ts
Comment thread packages/client-sdk-nodejs/src/config/function-configuration.ts
Code review round 2: import IFunctionClient/PutFunctionOptions from the public
@gomomento/sdk-core entrypoint instead of the internal dist path; fix the
addMiddleware JSDoc (it prepends, not appends).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

Comment thread packages/client-sdk-nodejs/src/config/function-configuration.ts
Comment thread packages/client-sdk-nodejs/src/config/function-configuration.ts
Comment thread packages/client-sdk-nodejs/src/config/function-configuration.ts
Comment thread packages/core/src/index.ts Outdated
Comment thread packages/client-sdk-nodejs/src/config/function-configuration.ts
… from putFunction

FunctionInfo now exposes getCurrentVersion() (resolves the pinned/latest oneof,
as the Rust SDK does) and getLastUpdatedAt(). PutFunction.Success now carries the
full FunctionInfo the server already returns (getFunction()) instead of only
id+name.
Code review round 3: public client interfaces belong under core/src/clients (like
ILeaderboardClient), so move IFunctionClient + PutFunctionOptions out of
internal/clients/function. Correct the function-configuration JSDoc @returns to
FunctionConfiguration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

Comment thread packages/client-sdk-nodejs/src/internal/function-client.ts
Code review round 4: the shared CacheServiceErrorMapper renders a NOT_FOUND as a
cache-flavored CacheNotFoundError. Add FunctionNotFoundError (+ a
FUNCTION_NOT_FOUND_ERROR code) and remap NOT_FOUND in the function client so a
missing function surfaces the correct error. Verified live.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 24 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

Comment thread packages/core/src/messages/function-info.ts
Code review round 5: FunctionInfo is now returned by putFunction (PutFunction.Success)
as well as listFunctions; update the class docstring.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 22 out of 24 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • packages/client-sdk-nodejs/package-lock.json: Generated file

@eaddingtonwhite eaddingtonwhite marked this pull request as ready for review June 18, 2026 00:33

@anitarua anitarua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

@malandis malandis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blockers from me. I wasn't aware the various functions lifecycle methods were data plane? Seems like control plane but 👍

Comment on lines +50 to +51
// Deploying a function uploads the wasm artifact inline, so the deadline is more generous than the
// cache-data defaults.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to +67
// Wasm artifacts ship inline in the PutFunction request and can be large, so raise the gRPC message-size
// caps above the data-plane defaults (which are tuned for small cache items).
const MAX_MESSAGE_SIZE_BYTES = 32 * 1024 * 1024;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +27 to +29
public getFunction(): FunctionInfo {
return this._function;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getFunctionInfo?

@eaddingtonwhite eaddingtonwhite merged commit 30fa5d2 into main Jun 18, 2026
12 of 13 checks passed
@eaddingtonwhite eaddingtonwhite deleted the feat/function-client branch June 18, 2026 21:02
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.

5 participants