Skip to content

GCP.PubSubLite reference

Source: src/GCP/PubSubLite/AdminReservation.ts

A Pub/Sub Lite throughput reservation — a regional pool of publish and subscribe capacity that topics can consume.

Pub/Sub Lite reservations have no labels. Alchemy stamps alchemy-stack / alchemy-stage / alchemy-id into the reservation id so list / pnpm nuke:gcp can find them. reservationId and location replace the reservation; throughputCapacity updates in place.

Generated name

const reservation = yield* GCP.PubSubLite.AdminReservation("Capacity", {
throughputCapacity: "4",
});

Explicit id and region

const reservation = yield* GCP.PubSubLite.AdminReservation("Capacity", {
reservationId: "analytics",
location: "us-central1",
throughputCapacity: "8",
});

Re-declare the same logical id with changed props; the engine keeps the physical resource and updates it in place.

const reservation = yield* GCP.PubSubLite.AdminReservation("Capacity", {
location: "us-central1",
throughputCapacity: "16",
});

Source: src/GCP/PubSubLite/AdminSubscription.ts

A Pub/Sub Lite subscription — a named consumer of a Lite topic.

Pub/Sub Lite subscriptions have no labels. Alchemy stamps alchemy-stack / alchemy-stage / alchemy-id into the subscription id so list / pnpm nuke:gcp can find them. subscriptionId, location, and topic replace the subscription. Delivery and export settings update in place. skipBacklog is create-only.

AdminSubscription: Creating a Subscription

Section titled “AdminSubscription: Creating a Subscription”

Pull subscription on a topic

const topic = yield* GCP.PubSubLite.AdminTopic("Events", {});
const subscription = yield* GCP.PubSubLite.AdminSubscription("Inbox", {
topic: topic.name,
});

Deliver after stored

const subscription = yield* GCP.PubSubLite.AdminSubscription("Inbox", {
topic: topic.name,
deliveryConfig: { deliveryRequirement: "DELIVER_AFTER_STORED" },
});
const lite = yield* GCP.PubSubLite.AdminTopic("Events", {});
const classic = yield* GCP.PubSub.Topic("Mirror", {});
const exported = yield* GCP.PubSubLite.AdminSubscription("Export", {
topic: lite.name,
exportConfig: {
desiredState: "ACTIVE",
pubsubConfig: { topic: classic.name },
},
});

Source: src/GCP/PubSubLite/AdminTopic.ts

A Pub/Sub Lite topic — a zonal or regional partitioned log.

Pub/Sub Lite topics have no labels. Alchemy stamps alchemy-stack / alchemy-stage / alchemy-id into the topic id so list / pnpm nuke:gcp can find them. topicId and location replace the topic. Partition count can only increase in place; shrinking it replaces the topic. Capacity, retention, and reservation attachment update in place.

Zonal topic with generated name

const topic = yield* GCP.PubSubLite.AdminTopic("Events", {});

Explicit capacity and retention

const topic = yield* GCP.PubSubLite.AdminTopic("Events", {
location: "us-central1-a",
partitionConfig: {
count: 1,
capacity: { publishMibPerSec: 4, subscribeMibPerSec: 8 },
},
retentionConfig: { perPartitionBytes: "32212254720", period: "86400s" },
});
const reservation = yield* GCP.PubSubLite.AdminReservation("Capacity", {
location: "us-central1",
throughputCapacity: "4",
});
const topic = yield* GCP.PubSubLite.AdminTopic("Events", {
location: "us-central1",
reservationConfig: { throughputReservation: reservation.name },
});

Source: src/GCP/PubSubLite/CommitCursor.ts

Runtime binding for Pub/Sub Lite cursor.commitCursor.

Bind this operation to an AdminSubscription in a Function/Action init phase. Provide CommitCursorHttp.

Grants roles/pubsublite.subscriber on the project: Pub/Sub Lite has no resource-level IAM.

const commit = yield* GCP.PubSubLite.CommitCursor(inbox);
yield* commit({
body: { partition: "0", cursor: { offset: "10" } },
});

Source: src/GCP/PubSubLite/CommitCursorHttp.ts Kind: Layer · Provides: GCP.PubSubLite.CommitCursor

HTTP implementation of CommitCursor.

Source: src/GCP/PubSubLite/ComputeHeadCursor.ts

Runtime binding for Pub/Sub Lite topicStats.computeHeadCursor.

Bind this operation to an AdminTopic in a Function/Action init phase. Provide ComputeHeadCursorHttp.

Grants roles/pubsublite.subscriber on the project: Pub/Sub Lite has no resource-level IAM.

ComputeHeadCursor: Computing the Head Cursor

Section titled “ComputeHeadCursor: Computing the Head Cursor”
const computeHead = yield* GCP.PubSubLite.ComputeHeadCursor(events);
const { headCursor } = yield* computeHead({
body: { partition: "0" },
});

Source: src/GCP/PubSubLite/ComputeHeadCursorHttp.ts Kind: Layer · Provides: GCP.PubSubLite.ComputeHeadCursor

HTTP implementation of ComputeHeadCursor.

Source: src/GCP/PubSubLite/GetPartitions.ts

Runtime binding for Pub/Sub Lite topics.getPartitions.

Bind this operation to an AdminTopic in a Function/Action init phase. Provide GetPartitionsHttp.

Grants roles/pubsublite.viewer on the project: Pub/Sub Lite has no resource-level IAM.

const getPartitions = yield* GCP.PubSubLite.GetPartitions(events);
const { partitionCount } = yield* getPartitions();

Source: src/GCP/PubSubLite/GetPartitionsHttp.ts Kind: Layer · Provides: GCP.PubSubLite.GetPartitions

HTTP implementation of GetPartitions.

Source: src/GCP/PubSubLite/GetReservation.ts

Runtime binding for Pub/Sub Lite reservations.get.

Bind this operation to an AdminReservation in a Function/Action init phase. Provide GetReservationHttp.

Grants roles/pubsublite.viewer on the project: Pub/Sub Lite has no resource-level IAM.

const getReservation = yield* GCP.PubSubLite.GetReservation(capacity);
const live = yield* getReservation();

Source: src/GCP/PubSubLite/GetReservationHttp.ts Kind: Layer · Provides: GCP.PubSubLite.GetReservation

HTTP implementation of GetReservation.

Source: src/GCP/PubSubLite/GetSubscription.ts

Runtime binding for Pub/Sub Lite subscriptions.get.

Bind this operation to an AdminSubscription in a Function/Action init phase. Provide GetSubscriptionHttp.

Grants roles/pubsublite.viewer on the project: Pub/Sub Lite has no resource-level IAM.

const getSubscription = yield* GCP.PubSubLite.GetSubscription(inbox);
const live = yield* getSubscription();

Source: src/GCP/PubSubLite/GetSubscriptionHttp.ts Kind: Layer · Provides: GCP.PubSubLite.GetSubscription

HTTP implementation of GetSubscription.

Source: src/GCP/PubSubLite/GetTopic.ts

Runtime binding for Pub/Sub Lite topics.get.

Bind this operation to an AdminTopic in a Function/Action init phase. Provide GetTopicHttp.

Grants roles/pubsublite.viewer on the project: Pub/Sub Lite has no resource-level IAM.

const getTopic = yield* GCP.PubSubLite.GetTopic(events);
const live = yield* getTopic();

Source: src/GCP/PubSubLite/GetTopicHttp.ts Kind: Layer · Provides: GCP.PubSubLite.GetTopic

HTTP implementation of GetTopic.