LaserData Cloud
Laser SDK

Connect

Connect with a connection string or from a LaserData API key, set TLS, timeouts, and retries, pick a default stream, and delete a stream when you are done

View as Markdownllms.txt

When LASER_CONNECTION_STRING is set, connect_env() is the whole connection and there is no server to start. Check it with echo "${LASER_CONNECTION_STRING:+configured}", which prints configured when it is. The rest of this page covers connecting any other way.

Create one connected client and share it. It carries authentication, transport, and connection state, and it reaches every stream on the server.

The Go client uses Apache Iggy over TCP. It accepts iggy:// and iggy+tcp:// connection strings. It also accepts the default TCP form without a scheme.

Connection strings

Pass a connection string to connect:

import { Laser } from "@laserdata/laser-sdk"

await using laser = await Laser.connect("iggy:iggy@127.0.0.1:8090")
use laser_sdk::prelude::*;

let laser = Laser::connect("iggy:iggy@127.0.0.1:8090").await?;
import laser_sdk as ls

laser = await ls.Laser.connect("iggy:iggy@127.0.0.1:8090")
client, err := laser.Connect(ctx, "iggy:iggy@127.0.0.1:8090")
if err != nil {
    return err
}
defer client.Close()

Use user:pwd@host:port or token@host:port. The port is optional and defaults to 8090, the Apache Iggy TCP port:

# username and password
iggy:iggy@127.0.0.1:8090

# a token in place of user:pwd
<token>@starter-123.us-west-1.aws.laserdata.cloud:8090

The scheme selects the transport. Every transport here is a stateful binary connection, so every SDK feature works the same over each:

SchemeTransportDefault portRustPythonTypeScriptGo
none, iggy://, iggy+tcp://TCP, plain or TLS8090yesyesyesyes
iggy+quic://QUIC over UDP, always encrypted8080yesyesnono
iggy+ws://WebSocket, plain or TLS8092yesyesnono

TypeScript is built on the Apache Iggy Node client, which connects over TCP only, so it refuses iggy+quic:// and iggy+ws:// with a message that names its transport. Every client refuses iggy+http://, since HTTP has no binary request path for Laser's features.

Rust, Python, TypeScript, and Go read the string with these rules, and every broken rule is a configuration error before any connection attempt:

  • The scheme is optional and selects the transport from the table above.
  • Credentials are required and percent-decoded, so a :, @, ? or % inside a username, password or token is written %3A, %40, %3F or %25. An empty user, password, or token, a raw @ or second raw : inside the credentials, or a malformed escape is refused.
  • The address is host or host:port. A present port must be a number from 1 to 65535. IPv6 literals, paths, and fragments are refused.
  • The options are exactly the ones Apache Iggy reads for the transport. TCP takes tls, tls_domain, tls_ca_file, reconnection_retries, reconnection_interval, reestablish_after, heartbeat_interval, nodelay, max_pending_operations, and max_pending_operation_bytes. WebSocket takes tls, tls_domain, tls_ca_file, tls_validate_certificate, the reconnection and heartbeat options, buffer, message and frame sizes, accept_unmasked_frames, and the two pending operation limits. QUIC takes validate_certificate, reconnection_max_retries, reconnection_interval, reconnection_reestablish_after, heartbeat_interval, window, buffer, MTU and timeout options, and the two pending operation limits. Names are case-sensitive and each appears at most once as key=value. An unknown, repeated, or malformed option, or an empty ?, is refused with a message that lists the transport's options.
  • Boolean options take only true or false.

To keep the credentials apart from the address, pass them separately:

const laser = await Laser.builder()
  .address("127.0.0.1", 8090)
  .credentials("iggy", "iggy")
  .connect()
let laser = Laser::builder()
    .address("127.0.0.1:8090")
    .credentials("iggy", "iggy")
    .build()
    .await?;
laser = await ls.Laser.connect(
    address="127.0.0.1:8090",
    credentials=("iggy", "iggy"),
)
client, err := laser.ConnectWith(ctx, "", laser.Options{
    Address:  "127.0.0.1:8090",
    Username: "iggy",
    Password: "iggy",
})
if err != nil {
    return err
}
defer client.Close()

Pick one form per client. The builder fails without credentials, as the string does. Connection string credentials are percent-decoded, so a :, @, ? or % inside a username, password or token is written %3A, %40, %3F or %25. The builder's credentials(user, password) takes both parts as given, any character included. The builder port is optional too and defaults to 8090.

Laser::local() in Rust, Laser.local() in TypeScript and Python, and laser.Local(ctx) in Go connect to iggy:iggy@127.0.0.1:8090. Laser Stack uses iggy:laser by default, so use the connection string it prints:

export LASER_CONNECTION_STRING='iggy:laser@127.0.0.1:8090'

LaserData Cloud

A LaserData Cloud deployment shows its connection string on the Credentials tab of the deployment in the console. It looks like ld-admin:<password>@<deployment-domain>:8090, the login of the deployment admin, and the SDK turns on TLS for it by itself. ld-admin has full data rights and no user or server administration, which covers every Laser SDK feature. Keep it in LASER_CONNECTION_STRING and never print or log it.

A deployment serves TCP on 8090 and WebSocket with TLS on 8070, so a WebSocket string names its port: iggy+ws://ld-admin:<password>@<deployment-domain>:8070. QUIC listens on 8080 over UDP only when the deployment's Iggy configuration turns it on, and Free deployments do not serve it. Over TCP and WebSocket the SDK verifies the server with the LaserData root CA it bundles. Apache Iggy's QUIC client verifies only against the operating system trust store and reads no CA file, so to use QUIC with LaserData Cloud, install the LaserData root CA in the system trust store first. Each transport needs its own access rule protocol: iggy_tcp, iggy_websocket, or iggy_udp for QUIC.

The deployment accepts a connection only from an address an access rule allows. A Free deployment comes with the global rule 0.0.0.0/0, so it needs no rule of yours unless that rule was deleted. For a paid deployment, or a Free one whose global rule is gone, add a rule for the public address your application connects from, with the tcp protocol, before you connect. Allow my IP does it in one call, see Agent access. Without it the connection is dropped and the connect fails after its budget with a timeout error that names the Iggy server to accept the connection. A wrong password fails at once with an authentication error instead.

From an API key

An agent or a CI job that has a LaserData API key and no connection string can get one in three REST calls. The key's role needs deployment:read and deployment:credentials:read on the deployment's environment, and none of the calls needs info:read. Each call sends the key in the ld-api-key header and a descriptive User-Agent, because the API's edge protection rejects some library default agents with 403 and error code: 1010.

  1. GET https://api.laserdata.cloud/tenants returns the key's organization. Take its id.
  2. GET https://api.laserdata.cloud/tenants/{tenant_id}/deployments?results=100 lists every deployment the key can read under items, each with its id, name, and supervisor_url. Pick one by its exact name or ID, and read further pages while page is below total_pages.
  3. GET {supervisor_url}/deployments/{deployment_id}/credentials returns connection_string, ready for connect(), with the password percent-encoded. Use it as it is, without building the string yourself.

The connection string signs in as ld-admin. The response adds a root login only for a key whose role also holds deployment:manage. Each task guide, such as Workflows, carries a resolve block that makes these calls in TypeScript, Rust, Python, and Go, and Agent access explains each case. The MCP endpoints serve the same calls as tools. A paid deployment also needs an access rule for the address the app connects from. Keep the connection string and the key out of logs and output, and give the key no wider role than the task needs.

Environment variables

Laser::connect_env() in Rust, Laser.connectEnv() in TypeScript, Laser.connect_env() in Python, and laser.ConnectEnv(ctx) in Go read the environment:

await using laser = await Laser.connectEnv()
let laser = Laser::connect_env().await?;
laser = await ls.Laser.connect_env()
client, err := laser.ConnectEnv(ctx)
if err != nil {
    return err
}
defer client.Close()
VariableEffect
LASER_CONNECTION_STRINGThe connection string, exactly what connect() takes. Required. The helpers return a configuration error without it
LASER_STREAMOptional default stream
LASER_TLS_CERTPath to a CA certificate file. Turns on TLS with this CA for any host and replaces the bundled LaserData CA
LASER_NO_TLS1, true, yes, or on turns off automatic TLS setup. Use it only for local development
LASER_CONNECT_TIMEOUT_MSThe budget for the first connect. See Connect timeout
LASER_PUBLISH_TIMEOUT_MS, LASER_PUBLISH_MAX_RETRIES, LASER_PUBLISH_RETRY_BACKOFF_MSPublish limits. See Publish timeouts and retries

To pick the default stream in code, Laser.connectEnvWithStream(stream) in TypeScript, Laser::connect_env_with_stream(stream) in Rust, and Laser.connect_env(stream=...) in Python read the same variables and take the stream, which wins over LASER_STREAM.

TypeScript's connectEnv also takes an environment map in place of process.env. The SDK does not read LASER_SERVER, LASER_TOKEN, LASER_USERNAME, or LASER_PASSWORD. Some examples use them to build LASER_CONNECTION_STRING.

Token or password

Use <token>@host:port for a token or user:pwd@host:port for a username and password. Tokens suit services and CI. A username and password suit local development. A token is a personal access token of a streaming-server user: sign in as that user and create one with laser.personal_access_token(name).create(expiry), see Server administration. A LaserData API key is a different credential and never goes in a connection string.

Both sign in an Iggy user with stream and topic permissions. A permission failure is a typed error. Rust has is_permission_denied(), Python sets permission_denied on the exception, TypeScript has isPermissionDenied(error), and Go has laser.IsPermissionDenied(err).

TLS

For *.laserdata.cloud and *.laserdata.com hosts, the SDK turns on TLS with the bundled LaserData root CA over TCP and WebSocket, and certificate validation over QUIC, which uses the system trust store. Other hosts keep the TLS settings of their connection string.

  • LASER_TLS_CERT=<path> or the tls_ca_file= parameter selects your own CA instead of the bundled one.
  • tls_ca_file= turns TLS on by itself. tls=true next to it is allowed, and tls=false next to it is a configuration error.
  • An explicit tls=false without a CA file turns off automatic TLS for LaserData hosts and for LASER_TLS_CERT.
  • LASER_NO_TLS=1 turns off automatic TLS setup. 0 and false do not. It never overrides a tls_ca_file= in the connection string, which still turns TLS on.

Connect timeout

The first connect has a 30 second budget. It covers the TCP connection, the TLS handshake, the login, and the managed capability probe. The Iggy client retries a failed connection by itself until the budget runs out.

Rust builderPython Laser.connectTypeScript builderEnvironment variableDefault
connect_timeout(Duration)connect_timeout_ms=connectTimeout(ms)LASER_CONNECT_TIMEOUT_MS30000

An explicit setting wins over the variable. The budget must be positive and at most 2147483647 milliseconds. An invalid value fails before any connection attempt.

When the budget runs out, the connect fails with a timeout error that names the stage that stopped. the Iggy server to accept the connection means the TCP or TLS handshake did not finish. the Iggy login reply means the transport was up but the server did not answer the login. TypeScript drops the leading the, and for a client you supply it can also report Iggy client readiness.

If only the capability probe is still open when the budget runs out, the connect succeeds with the baseline capability set. capabilities() probes again by itself when the set it holds has no managed backend, or has an enabled backend that is not ready yet, and its last probe is at least one second old. Callers that ask at the same time share one probe. refresh_capabilities() always probes.

const laser = await Laser.builder()
  .connectionString("iggy:iggy@127.0.0.1:8090")
  .connectTimeout(10_000)
  .connect()
use std::time::Duration;

let laser = Laser::builder()
    .connection_string("iggy:iggy@127.0.0.1:8090")
    .connect_timeout(Duration::from_secs(10))
    .build()
    .await?;
laser = await ls.Laser.connect(
    "iggy:iggy@127.0.0.1:8090",
    connect_timeout_ms=10_000,
)
client, err := laser.ConnectWith(ctx, "iggy:iggy@127.0.0.1:8090", laser.Options{Timeout: 10 * time.Second})
if err != nil {
    return err
}
defer client.Close()

Reconnection

The connect budget applies only to the first connect. After a lost connection, the client reconnects without a limit by default, once a second, so long-running consumers survive a server restart. After it reconnects, it signs in again with the connection string credentials. Change this with connection string parameters:

user:pwd@host:8090?reconnection_retries=<count|unlimited>&reconnection_interval=<duration>

Durations look like 250ms, 1s, or 1m. The other options are tls, tls_domain, tls_ca_file, heartbeat_interval, reestablish_after, and nodelay. TypeScript checks reestablish_after but its Node transport reconnects on its own schedule.

Publish timeouts and retries

Each publish attempt has a 60 second timeout and up to three more attempts. Retry delays start at 250 milliseconds, double after each failure, and stop at 30 seconds. The timeout bounds one attempt. The transport can report a failure sooner.

SettingRust builderPython Laser.connectTypeScript builderEnvironment variableDefault
Attempt timeoutpublish_timeout(Duration)publish_timeout_ms=publishTimeout(ms)LASER_PUBLISH_TIMEOUT_MS60000
More attemptspublish_max_retries(n)publish_max_retries=publishMaxRetries(n)LASER_PUBLISH_MAX_RETRIES3
First retry delaypublish_retry_backoff(Duration)publish_retry_backoff_ms=publishRetryBackoff(ms)LASER_PUBLISH_RETRY_BACKOFF_MS250

Explicit settings win over the variables. Set retries to zero to turn off automatic resends. The timeout and the delay must be positive and at most 2147483647 milliseconds. Invalid settings fail before the connection opens.

const laser = await Laser.builder()
  .connectionString("iggy:iggy@127.0.0.1:8090")
  .publishTimeout(90_000)
  .publishMaxRetries(5)
  .publishRetryBackoff(500)
  .connect()
use std::time::Duration;

let laser = Laser::builder()
    .connection_string("iggy:iggy@127.0.0.1:8090")
    .publish_timeout(Duration::from_secs(90))
    .publish_max_retries(5)
    .publish_retry_backoff(Duration::from_millis(500))
    .build()
    .await?;
laser = await ls.Laser.connect(
    "iggy:iggy@127.0.0.1:8090",
    publish_timeout_ms=90000,
    publish_max_retries=5,
    publish_retry_backoff_ms=500,
)
client, err := laser.ConnectWith(ctx, "iggy:iggy@127.0.0.1:8090", laser.Options{Publish: &laser.PublishOptions{
    Timeout: 90 * time.Second, MaxRetries: 5, RetryBackoff: 500 * time.Millisecond,
}})
if err != nil {
    return err
}
defer client.Close()

The variables apply to the builders and the connect helpers, and to TypeScript's Laser.fromClient. Rust's Laser::from_client uses the built-in defaults because it cannot return an error. To configure a client you supply in Rust, use Laser::builder().client(client). That client must already be connected and signed in.

These settings cover fluent, typed, agent, and direct producer publishes. A producer that sets its own retry count or delay keeps it, and one that leaves them unset inherits the connection values. A background producer returns once its queue accepts the records, so the publish timeout does not cover that step. See Producing at volume.

What triggers a retry

A timeout or a temporary connection failure triggers a retry within the limits. An Unauthenticated reply on a connection that had signed in before also triggers recovery, because a reconnect or a leader change can land on a node that holds no session for the client. The SDK reconnects with the connection string credentials, then retries. Permission errors, rejected credentials, invalid requests, and malformed commit confirmations fail at once.

Reconnecting before a retry uses time from that attempt. TypeScript spends at most half of the attempt on reconnecting, so time is left to send. After an attempt times out, Rust can spend one more timeout period closing the old connection and reconnecting. Rust reconnects the shared client in place, so consumers and reply readers keep their connection. TypeScript closes a failed socket and rejoins registered consumer groups on the new one. A client you supply in TypeScript has no connection recipe, so you must replace it after a failure.

Retries keep message IDs, payloads, headers, and routing. Delivery stays at least once. A lost acknowledgement can deliver a record twice, so effects must be safe to repeat.

Longer outages

When retries run out, Rust returns an error, Python raises a typed exception, and TypeScript rejects the promise. Nothing panics or exits. The error reports what was confirmed and what was not:

LanguageErrorConfirmed rangesRecords without a confirmationOriginal error
RustLaserError::PublishFailedcommittedunconfirmedpublish_cause()
TypeScriptPublishFailedErrorcommittedunconfirmedpublishCause(), or the free publishCause(error)
PythonPublishFailedErrorcommittedunconfirmed__cause__
Go*laser.PublishFailureCommittedUnconfirmedCause

All four also carry stream and topic. The retryable and permission checks answer for the original error: Rust is_retryable() and is_permission_denied(), TypeScript isRetryable(error) and isPermissionDenied(error), the Python retryable and permission_denied attributes, and Go laser.RetryableError(err) and laser.IsPermissionDenied(err). A permanent error, such as a missing resource or a denied permission, is not retryable. Do not publish the confirmed records again. See When a publish fails.

The SDK has no durable queue for offline publishes. A long-running service keeps failed work in its own durable queue, slows intake during an outage, and retries later. Keep retry limits finite. Consumer and agent tasks can also finish with an error, so watch their result and restart them.

Managed requests

Managed writes, such as a key-value set, a fork write or a control command, carry an operation ID that stays the same on every attempt, so a retry never applies a change twice. When the server answers that an outcome is still pending, or the connection fails after the request left, the SDK sends the same request again with growing, jittered delays. After 30 seconds without an outcome it returns an ambiguous-mutation error that names the operation. The change may still apply, so check the target state before you start new work.

Each client picks one node for its managed requests and stays on it until that node fails. Clients spread across the cluster because each one picks differently. The plane, the service behind managed data, can stop while Iggy and the machine keep running. When the connection drops or the node answers BackendUnavailable, the client moves to the next node and sends the same bytes with the same operation ID, so a write never runs twice. A request visits each node at most once per round. A write that every node refused is repeated by the write retry above, under its operation ID. A query stays on the node that started it for pages, status, and cancellation, because that node holds the query state. The official Iggy client owns the connections, also when you supply that client yourself.

A read that every node refused, with BackendUnavailable, with catalog_unavailable for a consumer filter catalog read, or with a dropped connection, is not returned yet. The client waits, from 100 ms doubling up to 2 seconds with jitter, and visits the nodes again until one serves the read or its deadline passes. The deadline is 30 seconds from the call, or the query's own deadline for a query. A node answers BackendUnavailable while it replays its logs after a restart. So on a single node, and on a cluster whose nodes all restart at once, a read waits for the replay instead of failing at the first refusal. On a cluster where another node still serves, the read moves there at once. When the deadline passes, the read fails with the last refusal: an error with the BackendUnavailable result code, the catalog_unavailable filter error, or the transport error of the dropped connection. Each is retryable, so is_retryable() in Rust, retryable in Python, and isRetryable(error) in TypeScript are true. Key-value, fork, graph, session, query, consumer filter catalog, filter test and preview, schema, projection, authorization, and client metadata reads wait this way. A consumer group reader's filtered reads and acknowledgments keep their own retries. To stop a read sooner, cancel it as Timeouts and cancellation describes.

Each key-value, fork, graph and session reply also tells the client how far the answering node has applied writes. The client keeps the furthest point it has seen and sends it with its next read of the same kind, so the node that answers waits until it has caught up that far, or answers Stale. A read never misses your own earlier writes and never shows older data than a read before it, whichever node answers. seen_positions() in Rust and Python and seenPositions() in TypeScript show these points.

Managed readiness

A successful connect gives you Iggy access. Queries, key-value state, forks, graph, and other managed features also need a ready backend, and a connected server can still be replaying managed state.

capabilities() returns the capability snapshot. Refresh it after startup or a backend restart, or wait for readiness with a deadline:

const fresh = await laser.refreshCapabilities()
const ready = await laser.waitUntilReady(30_000)
console.log(fresh.kv.available, ready.query.available)
use std::time::Duration;

let fresh = laser.refresh_capabilities().await;
let ready = laser.wait_until_ready(Duration::from_secs(30)).await?;
println!("{} {}", fresh.kv.available, ready.query.available);
fresh = await laser.refresh_capabilities()
ready = await laser.wait_until_ready(30_000)
print(fresh.kv.available, ready.query.available)
fresh := client.RefreshCapabilities(ctx)
ready, err := client.WaitUntilReady(ctx, 30*time.Second)
if err != nil {
    return err
}
fmt.Println(fresh.Kv.Available, ready.Query.Available)

The wait takes milliseconds in TypeScript and Python and a Duration in Rust. It reports unsupported when the server has no managed backend. A configured backend stays unavailable until replay finishes and it reports ready.

Capabilities include operation versions, backend descriptions, readiness reasons, and the hello outcome. is_open_only() reports a server with only baseline capabilities, and serves_consistency(level) reports a supported read consistency. TypeScript has these as free functions: isOpenOnly, servesConsistency, isReady, readinessReasons, enabledBackends, and unreadyBackends.

The SDK never repeats a lease acquisition after an unclear disconnect. See Key-value state in depth.

Timeouts and cancellation

Every relative duration is a Duration in Rust and milliseconds in TypeScript and Python, named for its unit (timeoutMs, timeout_ms). Python takes an int or a float. A negative, NaN, or infinite value fails with an invalid-argument error before anything is sent. An absolute time is epoch microseconds named with at, such as deadline_at_micros.

To give up on a call early, pass a signal in the trailing options of any TypeScript call that returns a promise, drop the future in Rust, or cancel the task in Python. An aborted TypeScript call rejects with CancelledError before it sends anything and while it waits, and a wait the server holds for it, such as a consumer poll, is cancelled. A cancelled publish sends no further retry. An abort does not undo a write that was already sent, so treat the outcome of an aborted publish or update as unknown.

const controller = new AbortController()
setTimeout(() => controller.abort(), 2_000)
const ready = await laser.waitUntilReady(30_000, { signal: controller.signal })
use std::time::Duration;

let ready = tokio::time::timeout(
    Duration::from_secs(2),
    laser.wait_until_ready(Duration::from_secs(30)),
)
.await;
async with asyncio.timeout(2):
    ready = await laser.wait_until_ready(30_000)
deadline, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
_, err := client.WaitUntilReady(deadline, 30*time.Second)
return err

Default stream

Without a default stream, address topics with the full path, laser.stream(name).topic(name). If most calls use one stream, pick it when you connect:

await using laser = await Laser.connectWithStream("iggy:iggy@127.0.0.1:8090", "telemetry")

// shorthand for laser.stream("telemetry").topic("host-metrics")
const metrics = laser.topic("host-metrics")
let laser = Laser::connect_with_stream("iggy:iggy@127.0.0.1:8090", "telemetry").await?;

// shorthand for laser.stream("telemetry").topic("host-metrics")
let metrics = laser.topic("host-metrics");
laser = await ls.Laser.connect("iggy:iggy@127.0.0.1:8090", stream="telemetry")

# shorthand for laser.stream("telemetry").topic("host-metrics")
metrics = laser.topic("host-metrics")
client, err := laser.ConnectWith(ctx, "iggy:iggy@127.0.0.1:8090", laser.Options{DefaultStream: "telemetry"})
if err != nil {
    return err
}
defer client.Close()

// shorthand for client.Stream("telemetry").Topic("host-metrics")
metrics := client.Topic("host-metrics")

Python also has connect_with_stream. The builders take the default as stream(name) in Rust and TypeScript. Other streams stay reachable through laser.stream(other).topic(name). Without a default stream, laser.topic(name) fails with a no-stream error. TypeScript throws NoStreamError from topic(name). Rust returns LaserError::NoStream and Python raises NoStreamError, a subclass of ConfigError, when you call an operation on the topic.

with_default_stream(name) in Rust and Python, or withDefaultStream(name) in TypeScript, returns a client with another default that shares the same connection.

Stream-scoped resource names

A client with a default stream scopes the managed resources it names to that stream. laser.kv("profiles") on a client whose default stream is telemetry addresses stream:telemetry/profiles. The same rule covers memory namespaces, lease and fence namespaces, the key registry, graph names, projection and index IDs, query indexes, fork IDs, and the change feed index filter. Each stream keeps its own managed data, and grants can name one stream's resources with a stream:<name>/ prefix.

  • A name that already starts with stream: is sent as is, so you can address another stream's resources.
  • Listings of namespaces, projections, and forks return only your stream's names, without the prefix.
  • Writer schemas are registered and looked up in the default stream's registry.
  • resource_name(name) (TypeScript resourceName) returns the name the client sends. A key-value handle reports its scoped namespace as resource_namespace (TypeScript resourceNamespace), and a fork handle reports its scoped ID as resource_id (TypeScript resourceId).
  • A client without a default stream sends bare names.
  • A record's projection selector stays the local projection ID. The backend matches it against the bindings of the record's own stream, so a record cannot select another stream's projection.
  • Consumer filter names are not scoped. A group's own filter belongs to its group, which already belongs to the stream.

Bare naming opts out and sends every name exactly as written. Use it to read data written under bare names:

const bare = laser.withResourceNaming("bare")
const profiles = bare.kv("profiles") // the namespace "profiles"
let bare = laser.with_resource_naming(ResourceNaming::Bare);
let profiles = bare.kv("profiles"); // the namespace "profiles"
bare = laser.with_resource_naming("bare")
profiles = bare.kv("profiles")  # the namespace "profiles"

# or for the whole connection
laser = await ls.Laser.connect("iggy:iggy@127.0.0.1:8090", stream="telemetry", resource_naming="bare")
bare := client.WithResourceNaming(laser.ResourceNamingBare)
profiles := bare.Kv("profiles") // the namespace "profiles"

// or for the whole connection
options := laser.Options{DefaultStream: "telemetry", ResourceNaming: laser.ResourceNamingBare}
client, err := laser.ConnectWith(ctx, "iggy:iggy@127.0.0.1:8090", options)
if err != nil {
    return err
}
defer client.Close()

The builders also take the choice: resource_naming(ResourceNaming::Bare) in Rust and resourceNaming("bare") in TypeScript. with_resource_naming returns a client that shares the connection.

A deployment that enforces stream scoping reports stream_tenancy in its capabilities (TypeScript streamTenancy). It refuses unscoped names and role grants that span streams, and it publishes each stream's change records on that stream's own change topic.

Server administration

The client also manages users and personal access tokens, reads the state of the server, settles requests with an unknown outcome, and sends raw Apache Iggy commands. The calls send native Apache Iggy commands, and the Iggy server applies its own permission checks to each one. A call from a user without the permission fails with the typed permission error that Token or password describes. On LaserData Cloud, the ld-admin login holds read_servers but not read_users, manage_users, or manage_servers, so user and server administration needs the root login, which Get Deployment Credentials returns to a caller that also holds deployment:manage.

The example lists the users, then reads the nodes of the cluster:

for (const user of await laser.users()) {
  console.log(user.id, user.username, user.status)
}

const cluster = await laser.cluster()
for (const node of cluster.nodes) {
  console.log(node.name, node.ip, node.tcpPort, node.role, node.status)
}
for user in laser.users().await? {
    println!("{} {} {}", user.id, user.username, user.status);
}

let cluster = laser.cluster().await?;
for node in cluster.nodes {
    println!("{} {} {} {} {}", node.name, node.ip, node.tcp_port, node.role, node.status);
}
for user in await laser.users():
    print(user.id, user.username, user.status)

cluster = await laser.cluster()
for node in cluster.nodes:
    print(node.name, node.ip, node.tcp_port, node.role, node.status)
users, err := client.Users(ctx)
if err != nil {
    return err
}
for _, user := range users {
    fmt.Println(user.ID, user.Username, user.Status)
}

cluster, err := client.Cluster(ctx)
if err != nil {
    return err
}
for _, node := range cluster.Nodes {
    fmt.Println(node.Name, node.IP, node.TCPPort, node.Role, node.Status)
}
CallWhat it does
laser.users()List every user of the server without permissions, as UserInfo values. Needs read_users
laser.user(name)Address one user by name. The call itself sends nothing
user.get()Read the user with its permissions, or no value when the user does not exist
user.exists()Return whether the user exists
user.create(password, options)Create the user. A new user is active and has no grants unless you give a status or permissions. A user with the same name fails the call
user.update(options)Rename the user or change its status. A field you leave unset keeps its value. After a rename, address the user by its new name
user.set_permissions(permissions)Replace every grant of the user. No value removes every grant
user.change_password(current, new)Change the password. The server checks the current password first
user.delete()Delete the user. Returns false when the user did not exist
laser.personal_access_tokens()List the tokens of the signed-in user, as PersonalAccessTokenInfo values
laser.personal_access_token(name).create(expiry)Create a token and return its value. The server shows the value only once. Without an expiry, the token never expires
laser.personal_access_token(name).delete()Delete the token. Returns false when the token did not exist
laser.ping()Ping the server
laser.stats()Read the server statistics, as a ServerStats value. Needs read_servers
laser.me()Read this connection as the server sees it, with its consumer groups, as a ClientInfo value
laser.clients()List the connected clients, as ClientInfo values. Needs read_servers
laser.client_info(id)Read one connected client with its consumer groups, or no value when no client has that ID. Needs read_servers
laser.cluster()Read the cluster name and its nodes, as a ClusterInfo value. A single server reports one node
laser.snapshot()Read a diagnostics snapshot as the bytes of a ZIP archive. Needs manage_servers
laser.describe_options(scope)List the options the server accepts for a topic, stream, or user, as OptionInfo values. An unknown scope fails with an invalid-argument error before the client sends anything
laser.metadata_changes(query)Read one page of the server's metadata changes, or of its current state, as a MetadataChanges value. Needs manage_servers
uncertain_operation(error)Return the request that a transport error left with an unknown outcome, or no value for any other failure
laser.resolve_operation(operation, timeout)Replay the request until the server proves its outcome or the timeout ends. Succeeds when the request committed and fails with the request's own error when the server refused it
laser.abandon_operation(operation)Give the request up. Its outcome stays unknown
laser.send_command(code, payload)Send one Apache Iggy command by its code with a raw payload, and return the raw reply. Refuses the sign-in, sign-out, and session commands before anything is sent
laser.send_command_to_replica(code, payload, replica)Send the command to one replica, numbered as laser.cluster() reports it, and return the reply of that replica

The user calls need the matching user permission on the connection. A user status is active or inactive, and an inactive user cannot sign in. To sign in with a personal access token, put its value in the connection string in place of the username and password, as in Connection strings. The snapshot holds the file system overview, the process list, the resource use, the server logs, and the server configuration.

When a request fails and the client cannot prove whether it committed, the transport error names that request. Read it with uncertain_operation: Rust LaserError::uncertain_operation and TransportError::uncertain_operation, Python TransportError.uncertain_operation, and TypeScript uncertainOperation(error). Then call resolve_operation or abandon_operation. Both calls free the requests that the unknown outcome blocked. send_command picks the node as it does for the typed call, and the server checks the permissions of the command. Only a command that a node answers from its own state can go to a replica. Another command, or a replica the cluster does not name, fails before anything is sent. Python takes timeout_ms and passes payloads as bytes. TypeScript uses resolveOperation(operation, timeoutMs), abandonOperation, sendCommand, and sendCommandToReplica, with the operation as a bigint and payloads as Uint8Array values.

Each OptionInfo holds the option key, its value kind such as uint64, its description, and its default as text, or no value when there is no default. Its flags tell whether an update can set or reset the option, and whether the option is secret, read-only, or critical.

A metadata_changes query names a start, the record groups, an optional time range in microseconds, and a page size from 1 to 1000, 100 by default. The start is earliest, latest, after a cursor, or current to page through the current state. No groups means every group. Pass the next cursor of a page to the after start to read on. After a page with the status expired or reset, read the current state again.

Python uses the same names and takes the options as keyword arguments: create(password, status=, permissions=), update(username=, status=), and create(expiry_ms=) for a token. Python also takes metadata_changes(start, groups=, since_micros=, until_micros=, limit=) with a start such as MetadataChangeStart.after(cursor). TypeScript uses setPermissions, changePassword, personalAccessTokens(), personalAccessToken(name), clientInfo(id), describeOptions(scope), and metadataChanges({ start, groups, sinceMicros, untilMicros, limit }) with a start such as { mode: "after", cursor }. It takes options objects: create(password, { status, permissions }), update({ username, status }), and create({ expiryMs }) for a token. Rust takes CreateUserOptions, UpdateUserOptions, an Option<Duration> expiry, an OptionsScope, and a MetadataChangesQuery with a MetadataChangeStart from the laser_sdk::server module. A missing user or client gives no value: None in Rust and Python, and undefined in TypeScript.

TypeFields
UserInfoid, username, status, created_at_micros, permissions
Permissionsglobal grants, and streams grants keyed by the native stream ID
PersonalAccessTokenInfoname, expires_at_micros
ClientInfoclient_id, user_id, address, transport, consumer_groups_count, consumer_groups
ClusterInfoname, nodes
ClusterNodereplica_id, name, ip, tcp_port, quic_port, http_port, websocket_port, role, status
ServerStatsCPU, memory, disk, thread, and open file use, bytes read and written, the counts of streams, topics, partitions, segments, messages, clients, and consumer groups, the host name, the operating system, kernel, and server versions, and cache metrics per partition
  • permissions has no value in a listing and for a user without grants. expires_at_micros has no value for a token that never expires. user_id has no value before the client signs in. consumer_groups is empty in a listing.
  • The global grants are manage_servers, read_servers, manage_users, read_users, manage_streams, read_streams, manage_topics, read_topics, poll_messages, and send_messages. A stream grant has manage_stream, read_stream, manage_topics, read_topics, poll_messages, send_messages, and topics, keyed by the native topic ID. A topic grant has manage_topic, read_topic, poll_messages, and send_messages. A grant you leave out is false.
  • Python gives permissions as a dict with global and streams keys. TypeScript keys the stream and topic grants with a Map.
  • A node role is leader or follower. A node status is healthy, starting, stopping, unreachable, maintenance, or unknown. A port is 0 when the node does not serve that transport.
  • Sizes are in bytes and times are in microseconds. created_at_micros and expires_at_micros count from the Unix epoch.
  • TypeScript uses camelCase field names. Sizes, times, message counts, open file counts, and cache hits and misses are bigint values.

Delete a stream

laser.stream(name).delete() removes a stream with all of its topics and messages. It returns false when the stream did not exist. Each partition costs the server open files and memory, so delete streams you no longer need, especially on small tiers. A scratch stream gets a unique name, {prefix}-{8 lowercase hex}, and is deleted when its scope ends, also when the code inside raised an error:

await laser.stream("telemetry").delete()

{
  await using scratch = await laser.scratchStream("demo")
  await scratch.laser.bootstrap()
  // Use scratch.laser here. The stream is deleted when this block ends.
}
laser.stream("telemetry").delete().await?;

let scratch = laser.scratch_stream("demo").await?;
scratch.laser().bootstrap(1, TopicRetention::default()).await?;
// Use scratch.laser() here, then delete it.
scratch.delete().await?;
await laser.stream("telemetry").delete()

async with laser.scratch_stream("demo") as scratch:
    await scratch.laser.bootstrap()
    # Use scratch.laser here. The stream is deleted when this block ends.
if _, err := client.Stream("telemetry").Delete(ctx); err != nil {
    return err
}

scratch, err := client.ScratchStream(ctx, "demo")
if err != nil {
    return err
}
// The stream is deleted when this function returns.
defer scratch.Delete(context.WithoutCancel(ctx))
if err := scratch.Laser().Bootstrap(ctx, 1, laser.ExpireAfter(time.Hour)); err != nil {
    return err
}
// Use scratch.Laser() here.

In Rust, a ScratchStream dropped without delete() also deletes its stream in a background task when a Tokio runtime is running, so call delete().await for a cleanup you can rely on. Stop the agents and consumers that use a stream before you delete it.

Close

close() ends the shared connection for every clone of the client. Consumers and reply readers on that connection lose it too. It also closes the fenced-lease connection when the client opened one. You can call it more than once.

TypeScript await using calls close() when the scope of the root client ends. Clones made with withDefaultStream, withResourceNaming, and the other with* methods do nothing on dispose. A client you hand to TypeScript with builder().client(c) or fromClient(c) is borrowed by default, so close() leaves it open. Pass { ownership: "owned" } to let close() destroy it. Python async with follows the same rule: the block closes a client a connect call returned, and a clone from with_default_stream or another with_* method only borrows the connection. Producers, consumers, batching producers, and filtered readers close on block exit too, with Python async with and TypeScript await using.

Live client presence lives on the node that received it. client_metadata().all() in Rust, client_metadata_all() in Python, and clientMetadata().all() in TypeScript ask every node and merge the results, paging each node on its own. A single-page request reads only the node you are connected to.

On this page