FluxbaseRPC
FluxbaseRPC provides methods for invoking RPC procedures
Example
Section titled “Example”// Invoke a procedure synchronouslyconst { data, error } = await fluxbase.rpc.invoke('get-user-orders', { user_id: '123', limit: 10});
// Invoke asynchronouslyconst { data: asyncResult } = await fluxbase.rpc.invoke('long-running-report', { start_date: '2024-01-01'}, { async: true });
// Poll for statusconst { data: status } = await fluxbase.rpc.getStatus(asyncResult.execution_id);Constructors
Section titled “Constructors”new FluxbaseRPC()
Section titled “new FluxbaseRPC()”new FluxbaseRPC(
fetch):FluxbaseRPC
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | RPCFetch |
Returns
Section titled “Returns”Methods
Section titled “Methods”getLogs()
Section titled “getLogs()”getLogs(
executionId,afterLine?):Promise<object>
Get execution logs (for debugging and monitoring)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
executionId | string | The execution ID |
afterLine? | number | Optional line number to get logs after (for polling) |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with execution logs
| Name | Type |
|---|---|
data | null | ExecutionLog[] |
error | null | Error |
Example
Section titled “Example”const { data: logs } = await fluxbase.rpc.getLogs('execution-uuid');for (const log of logs) { console.log(`[${log.level}] ${log.message}`);}getStatus()
Section titled “getStatus()”getStatus(
executionId):Promise<object>
Get execution status (for async invocations or checking history)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
executionId | string | The execution ID returned from async invoke |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with execution details
| Name | Type |
|---|---|
data | null | RPCExecution |
error | null | Error |
Example
Section titled “Example”const { data, error } = await fluxbase.rpc.getStatus('execution-uuid');if (data.status === 'completed') { console.log('Result:', data.result);} else if (data.status === 'running') { console.log('Still running...');}invoke()
Section titled “invoke()”invoke<
T>(name,params?,options?):Promise<object>
Invoke an RPC procedure
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | Procedure name |
params? | Record<string, unknown> | Optional parameters to pass to the procedure |
options? | RPCInvokeOptions | Optional invocation options |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with invocation response
| Name | Type |
|---|---|
data | null | RPCInvokeResponse<T> |
error | null | Error |
Example
Section titled “Example”// Synchronous invocationconst { data, error } = await fluxbase.rpc.invoke('get-user-orders', { user_id: '123', limit: 10});console.log(data.result); // Query results
// Asynchronous invocationconst { data: asyncData } = await fluxbase.rpc.invoke('generate-report', { year: 2024}, { async: true });console.log(asyncData.execution_id); // Use to poll statuslist()
Section titled “list()”list(
namespace?):Promise<object>
List available RPC procedures (public, enabled)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
namespace? | string | Optional namespace filter |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of procedure summaries
| Name | Type |
|---|---|
data | null | RPCProcedureSummary[] |
error | null | Error |
waitForCompletion()
Section titled “waitForCompletion()”waitForCompletion(
executionId,options?):Promise<object>
Poll for execution completion with exponential backoff
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
executionId | string | The execution ID to poll |
options? | object | Polling options |
options.initialIntervalMs? | number | Initial polling interval in milliseconds (default: 500) |
options.maxIntervalMs? | number | Maximum polling interval in milliseconds (default: 5000) |
options.maxWaitMs? | number | Maximum time to wait in milliseconds (default: 30000) |
options.onProgress? | (execution) => void | Callback for progress updates |
Returns
Section titled “Returns”Promise<object>
Promise resolving to final execution state
| Name | Type |
|---|---|
data | null | RPCExecution |
error | null | Error |
Example
Section titled “Example”const { data: result } = await fluxbase.rpc.invoke('long-task', {}, { async: true });const { data: final } = await fluxbase.rpc.waitForCompletion(result.execution_id, { maxWaitMs: 60000, // Wait up to 1 minute onProgress: (exec) => console.log(`Status: ${exec.status}`)});console.log('Final result:', final.result);