Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ ignore_missing_imports = True
# TODO: https://github.com/grpc/grpc/issues/29041
ignore_missing_imports = True

[mypy-hello.v1.*]
[mypy-chat_room.v1.*]
# TODO: See https://github.com/reboot-dev/mono/issues/2859
ignore_errors = True
12 changes: 6 additions & 6 deletions .rbtrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ dev run --watch=backend/src/**/*.py
dev run --python

# Set the application name for commands that require it.
cloud up --name=hello
cloud down --name=hello
dev expunge --name=hello
dev run --name=hello
serve run --name=hello
cloud up --name=chat-room
cloud down --name=chat-room
dev expunge --name=chat-room
dev run --name=chat-room
serve run --name=chat-room

# Run the application!
dev run --application=backend/src/main.py
Expand All @@ -60,4 +60,4 @@ serve run --tls=external
# Run the application!
serve run --application=backend/src/main.py

cloud logs --name=hello
cloud logs --name=chat-room
4 changes: 2 additions & 2 deletions .tests/serve_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ stop_container() {
}

perform_curl() {
local url="localhost:8787/hello.v1.HelloMethods/Messages"
local url="localhost:8787/chat_room.v1.ChatRoomMethods/Messages"
local headers=(
"-H" "x-reboot-state-ref:hello.v1.Hello:reboot-hello"
"-H" "x-reboot-state-ref:chat_room.v1.ChatRoom:reboot-chat-room"
)
local actual_output_file="$1"

Expand Down
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ filegroup(
# as manually following the steps of the `README.md` file, but which
# are not part of the "source code" of this repository.
".venv/**/*",
".reboot-hello-venv/**/*",
".reboot-chat-room-venv/**/*",
".pytest_cache/**/*",
"api/gen/**/*.js",
"web/node_modules/**/*",
Expand All @@ -29,5 +29,5 @@ write_templated_source_file(
name = "README_md",
src = "//reboot/examples:README.j2.md",
dest = "README.md",
input_yaml = "//reboot/examples:hello_README.md.yaml",
input_yaml = "//reboot/examples:chat_room_README.md.yaml",
)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/reboot-dev/reboot-base:0.39.3
FROM ghcr.io/reboot-dev/reboot-base:0.41.0

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For the impatient:

This repository contains a simple example application written using Reboot.

The [Reboot '.proto' definitions](https://docs.reboot.dev/develop/schema#code-generation)
The [Reboot '.proto' definitions](https://docs.reboot.dev/develop/define/overview/#code-generation)
can be found in the `api/` directory, grouped into
subdirectories by proto package, while backend specific code can be
found in `backend/` and front end specific code in `web/` and non-React front end in `reboot-non-react-web/`.
Expand Down
6 changes: 3 additions & 3 deletions api/hello/v1/hello.proto → api/chat_room/v1/chat_room.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
syntax = "proto3";

package hello.v1;
package chat_room.v1;

import "rbt/v1alpha1/options.proto";

////////////////////////////////////////////////////////////////////////

message Hello {
message ChatRoom {
option (rbt.v1alpha1.state) = {
};
repeated string messages = 1;
}

service HelloMethods {
service ChatRoomMethods {
// Returns the current list of recorded messages.
rpc Messages(MessagesRequest) returns (MessagesResponse) {
option (rbt.v1alpha1.method).reader = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hello.v1.hello_rbt import (
Hello,
from chat_room.v1.chat_room_rbt import (
ChatRoom,
MessagesRequest,
MessagesResponse,
SendRequest,
Expand All @@ -9,7 +9,7 @@
from reboot.aio.contexts import ReaderContext, WriterContext


class HelloServicer(Hello.Servicer):
class ChatRoomServicer(ChatRoom.Servicer):

def authorizer(self):
return allow()
Expand Down
12 changes: 6 additions & 6 deletions backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import asyncio
import logging
from hello.v1.hello_rbt import Hello
from hello_servicer import HelloServicer
from chat_room.v1.chat_room_rbt import ChatRoom
from chat_room_servicer import ChatRoomServicer
from reboot.aio.applications import Application
from reboot.aio.external import InitializeContext

logging.basicConfig(level=logging.INFO)

EXAMPLE_STATE_MACHINE_ID = 'reboot-hello'
EXAMPLE_STATE_MACHINE_ID = 'reboot-chat-room'


async def initialize(context: InitializeContext):
hello = Hello.ref(EXAMPLE_STATE_MACHINE_ID)
chat_room = ChatRoom.ref(EXAMPLE_STATE_MACHINE_ID)

# Implicitly construct state machine upon first write.
await hello.send(
await chat_room.send(
context,
message="Hello, World!",
)
Expand All @@ -24,7 +24,7 @@ async def initialize(context: InitializeContext):

async def main():
await Application(
servicers=[HelloServicer],
servicers=[ChatRoomServicer],
initialize=initialize,
).run()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from hello.v1.hello_rbt import Hello
from hello_servicer import HelloServicer
from chat_room.v1.chat_room_rbt import ChatRoom
from chat_room_servicer import ChatRoomServicer
from reboot.aio.applications import Application
from reboot.aio.tests import Reboot

Expand All @@ -14,22 +14,21 @@ async def asyncSetUp(self) -> None:
async def asyncTearDown(self) -> None:
await self.rbt.stop()

async def test_hello(self) -> None:
await self.rbt.up(Application(servicers=[HelloServicer]))
async def test_chat_room(self) -> None:
await self.rbt.up(Application(servicers=[ChatRoomServicer]))

context = self.rbt.create_external_context(name=f"test-{self.id()}")

hello = Hello.ref("testing-hello")
chat_room = ChatRoom.ref("testing-chat-room")

await hello.send(context, message="Hello, World")

response: Hello.MessagesResponse = await hello.messages(context)
await chat_room.send(context, message="Hello, World")

response: ChatRoom.MessagesResponse = await chat_room.messages(context)
self.assertEqual(response.messages, ["Hello, World"])

await hello.send(context, message="Hello, Reboot!")
await hello.send(context, message="Hello, Peace of Mind!")
response = await hello.messages(context)
await chat_room.send(context, message="Hello, Reboot!")
await chat_room.send(context, message="Hello, Peace of Mind!")
response = await chat_room.messages(context)
self.assertEqual(
response.messages,
[
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[project]
requires-python = ">= 3.10"
dependencies = [
"reboot==0.39.3",
"reboot==0.41.0",
]

[tool.rye]
dev-dependencies = [
"mypy==1.18.1",
"pytest>=7.4.2",
"types-protobuf>=4.24.0.20240129",
"reboot==0.39.3",
"reboot==0.41.0",
]

# This project only uses `rye` to provide `python` and its dependencies, so
Expand Down
22 changes: 14 additions & 8 deletions reboot-non-react-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion reboot-non-react-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@bufbuild/protobuf": "1.10.1",
"@reboot-dev/reboot-web": "^0.39.3",
"@reboot-dev/reboot-web": "^0.41.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
Expand Down
12 changes: 6 additions & 6 deletions reboot-non-react-web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { WebContext } from "@reboot-dev/reboot-web";
import { Hello } from "../../web/src/api/hello/v1/hello_rbt_web";
import { ChatRoom } from "../../web/src/api/chat_room/v1/chat_room_rbt_web";

const root = document.getElementById("messages");
const button = document.getElementById("button");

const context = new WebContext({
url: "http://localhost:9991",
});
const hello = Hello.ref("reboot-hello");
const chatRoom = ChatRoom.ref("reboot-chat-room");

button!.addEventListener("click", async () => {
const inputElement = document.getElementById("input") as HTMLInputElement;
Expand All @@ -20,7 +20,7 @@ async function handleClick(element: HTMLInputElement) {
return;
}

await hello.send(context, {
await chatRoom.send(context, {
message: message,
});

Expand All @@ -29,7 +29,7 @@ async function handleClick(element: HTMLInputElement) {

async function bindToElement(
element: HTMLElement,
generator: AsyncGenerator<Hello.MessagesResponse>
generator: AsyncGenerator<ChatRoom.MessagesResponse>
) {
for await (const response of generator) {
element.innerHTML = `${response.messages
Expand All @@ -38,8 +38,8 @@ async function bindToElement(
}
}

const [responses] = await hello.reactively().messages(context);
const [responses] = await chatRoom.reactively().messages(context);

bindToElement(root!, responses);

console.log("Hello Reboot Web example is running!");
console.log("Chat Room Reboot Web example is running!");
4 changes: 2 additions & 2 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ python-dateutil==2.9.0.post0
pyyaml==6.0.2
# via kubernetes-asyncio
# via reboot
reboot==0.39.3
reboot==0.41.0
setuptools==75.1.0
# via grpcio-tools
six==1.16.0
Expand Down Expand Up @@ -203,7 +203,7 @@ uvicorn==0.34.0
# via reboot
watchdog==6.0.0
# via reboot
websockets==13.1
websockets==15.0.1
# via reboot
wrapt==1.16.0
# via deprecated
Expand Down
4 changes: 2 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ python-dateutil==2.9.0.post0
pyyaml==6.0.2
# via kubernetes-asyncio
# via reboot
reboot==0.39.3
reboot==0.41.0
setuptools==75.1.0
# via grpcio-tools
six==1.16.0
Expand Down Expand Up @@ -188,7 +188,7 @@ uvicorn==0.34.0
# via reboot
watchdog==6.0.0
# via reboot
websockets==13.1
websockets==15.0.1
# via reboot
wrapt==1.16.0
# via deprecated
Expand Down
Loading