Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ temporalio/bridge/temporal_sdk_bridge*
tags
/.claude
tmpclaude-*

# nexgen builds that scripts/gen_stream_service.py installs
/.nexgen-streams/
4 changes: 1 addition & 3 deletions scripts/_wit/stream-service.wit
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ world system {
/// @nexus.endpoint "__temporal_system"
/// @nexus.service-name "temporal.api.streamservice.v1.StreamService"
/// @nexus.experimental
/// @nexus.handle "stream-handle" keys="stream"
/// @nexus.handle "stream-producer" keys="stream producer"
interface stream-service {
use nexus:temporal-types/model@1.0.0.{
duration,
Expand Down Expand Up @@ -141,7 +139,7 @@ interface stream-service {
/// @nexus.doc "The place of this Record in the Stream. Ordered and unique, with gaps."
/// @nexus.offset "stream-offset"
offset: option<s64>,
/// @nexus.doc "Empty on a SUPERSEDED, close or IDLE Record, and for the default Topic."
/// @nexus.doc "Empty on CLOSE, IDLE and SUPERSEDED Records."
topic: option<string>,
producer: option<producer>,
/// @nexus.doc "Set on a data Record."
Expand Down
44 changes: 37 additions & 7 deletions scripts/gen_stream_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

The WIT and the protos are copies of the temporalio-streams crate's, in scripts/_wit and
scripts/_proto. Run scripts/gen_protos.py first for the proto modules. No nexgen release has the
offset, one-way, long-poll, handle and client features yet, so NEX_GEN_STREAMS_BIN must name an
advanced build of moetemp/nexgen moe/brook/v3/n9-handles.
offset, one-way, long-poll and client features yet, so the script installs nexgen at
NEX_GEN_REVISION from moetemp/nexgen. NEX_GEN_STREAMS_BIN may name a build of that revision
instead.
"""

import os
Expand All @@ -30,12 +31,37 @@
)
output_dir = base_dir / "temporalio" / "contrib" / "streams" / "system"

NEX_GEN_REPOSITORY = "https://github.com/moetemp/nexgen"
# The head of moe/brook/v3/n7-long-poll-loop. A branch moves, so the pin is the commit.
NEX_GEN_REVISION = "64ee48a79abe18077d727f5067a6302c45c25c9d"
nex_gen_root = base_dir / ".nexgen-streams" / NEX_GEN_REVISION


def nex_gen_command() -> list[str]:
bin_path = os.environ.get("NEX_GEN_STREAMS_BIN")
if not bin_path:
raise RuntimeError("set NEX_GEN_STREAMS_BIN to a nexgen build with --client")
return [bin_path]
if bin_path := os.environ.get("NEX_GEN_STREAMS_BIN"):
return [bin_path]
binary = nex_gen_root / "bin" / "nexgen"
if not binary.exists():
subprocess.check_call(
[
"cargo",
"install",
"--locked",
"nexgen",
"--git",
NEX_GEN_REPOSITORY,
"--rev",
NEX_GEN_REVISION,
"--features",
"advanced",
"--root",
str(nex_gen_root),
],
# The git CLI honours the user's URL rewrites and credentials, which cargo's
# built-in client does not.
env={**os.environ, "CARGO_NET_GIT_FETCH_WITH_CLI": "true"},
)
return [str(binary)]


def api_protos() -> list[Path]:
Expand Down Expand Up @@ -99,6 +125,10 @@ def generate_stream_service() -> None:


if __name__ == "__main__":
print("Generating the Stream service bindings...", file=sys.stderr)
print(
f"Generating the Stream service bindings with nexgen {NEX_GEN_REPOSITORY}"
f"@{NEX_GEN_REVISION}...",
file=sys.stderr,
)
generate_stream_service()
print("Done", file=sys.stderr)
Loading
Loading