Skip to content

Commit

Permalink
Add web frontend to hello-world.
Browse files Browse the repository at this point in the history
  • Loading branch information
rileysdev committed Sep 29, 2023
1 parent 4ca6cc1 commit 963d7a7
Show file tree
Hide file tree
Showing 31 changed files with 33,555 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .rsmrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ dev:hello-world --env=PYTHONPATH=api/
# Tell `rsm` that this is a Python application.
dev:hello-world --python

# Don't run chaos so we don't lose state.
dev:hello-world --no-chaos

# Run this application!
dev:hello-world hello-world/backend/src/main.py
84 changes: 84 additions & 0 deletions api/google/protobuf/descriptor_rsm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# yapf: disable
# isort: skip_file

# Standard imports.
import grpc
import traceback
import uuid
import resemble.aio.state_managers
from abc import abstractmethod
from datetime import datetime, timedelta
from google.protobuf import any_pb2
from google.protobuf.descriptor import FileDescriptor
from google.protobuf.message import Message
from google.rpc import code_pb2, status_pb2
from grpc_status import rpc_status
from resemble.aio.contexts import (
Context,
ReaderContext,
TransactionContext,
WriterContext,
)
from resemble.aio.errors import Aborted
from resemble.aio.headers import Headers
from resemble.aio.idempotency import IdempotencyManager, Idempotency
from resemble.aio.internals.channel_manager import _ChannelManager
from resemble.aio.internals.middleware import Middleware
from resemble.aio.internals.tasks_cache import TasksCache
from resemble.aio.internals.tasks_dispatcher import TasksDispatcher
from resemble.aio.headers import Headers
from resemble.aio.servicers import Servicer, Serviceable
from resemble.aio.state_managers import Effects, StateManager
from resemble.aio.stubs import Stub
from resemble.aio.tasks import TaskEffect
from resemble.aio.types import ActorId, assert_type, GrpcMetadata, ServiceName
from resemble.aio.workflows import Workflow
from typing import (
AsyncIterable,
AsyncIterator,
Awaitable,
Callable,
Optional,
TypeAlias,
Union,
)

# User defined or referenced imports.
import google.protobuf.descriptor_pb2
import google.protobuf.descriptor_pb2_grpc
# Additionally re-export all messages from the pb2 module.
from google.protobuf.descriptor_pb2 import (
DescriptorProto,
EnumDescriptorProto,
EnumOptions,
EnumValueDescriptorProto,
EnumValueOptions,
ExtensionRangeOptions,
FieldDescriptorProto,
FieldOptions,
FileDescriptorProto,
FileDescriptorSet,
FileOptions,
GeneratedCodeInfo,
MessageOptions,
MethodDescriptorProto,
MethodOptions,
OneofDescriptorProto,
OneofOptions,
ServiceDescriptorProto,
ServiceOptions,
SourceCodeInfo,
UninterpretedOption,
)


def MakeLegacyGrpcServiceable(
# A legacy gRPC servicer type can't be more specific than `type`,
# because legacy gRPC servicers (as generated by the gRPC `protoc`
# plugin) do not share any common base class other than `object`.
servicer_type: type
) -> Serviceable:
raise ValueError(f"Unknown legacy gRPC servicer type '{servicer_type}'")


# yapf: enable
47 changes: 47 additions & 0 deletions api/google/protobuf/descriptor_rsm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type {
PartialMessage
} from "@bufbuild/protobuf";
import {
Deferred,
Event,
IQueryRequest,
IQueryResponse,
Mutation,
QueryRequest,
QueryResponse,
ResponseOrError,
filterSet,
parseStreamedValue,
popMutationMaybeFromLocalStorage,
pushMutationMaybeToLocalStorage,
retryForever,
useResembleContext
} from "@reboot-dev/resemble-react";
import {
Dispatch,
MutableRefObject,
SetStateAction,
useEffect,
useRef,
useState,
} from "react";
import { v4 as uuidv4 } from "uuid";
// There are known bugs with the following input / output message imports:
// 1. It doesn't correctly handle input / output messages that don't have a
// corresponding const definition in the generated _pb,
// e.g. google.protobuf.Empty.
// 2. It will try to import the same message twice if any input message is the
// same as any output message.
// TODO: correctly handle messages like google.protobuf.Empty.
// TODO: create a set of input messages AND output messages and |map ..|unique
// over those to ensure there are no duplicates.
import {
,
} from "./descriptor_pb";


// Start of service specific code.
///////////////////////////////////////////////////////////////////////////



21 changes: 10 additions & 11 deletions api/hello_world/v1/greeter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,31 @@ import "resemble/v1alpha1/options.proto";
service Greeter {
option (resemble.v1alpha1.service).state = "GreeterState";

rpc Create(CreateRequest) returns (CreateResponse) {
option (resemble.v1alpha1.method).writer = {
constructor: true,
rpc Greetings(GreetingsRequest) returns (GreetingsResponse) {
option (resemble.v1alpha1.method).reader = {
};
}

rpc Greet(GreetRequest) returns (GreetResponse) {
option (resemble.v1alpha1.method).reader = {
option (resemble.v1alpha1.method).writer = {
};
}
}

message GreeterState {
string greeting = 1;
repeated string greetings = 2;
}

message CreateRequest {
string greeting = 1; // E.g. "Hello".
}
message GreetingsRequest {}

message CreateResponse {}
message GreetingsResponse {
repeated string greetings = 1;
}

message GreetRequest {
string name = 1; // E.g. "World".
string greeting = 1; // E.g. "Hello, World".
}

message GreetResponse {
string message = 1; // E.g. "Hello, World!".
string greeting = 1;
}
125 changes: 125 additions & 0 deletions api/hello_world/v1/greeter_pb.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// @generated by protoc-gen-es v1.3.1
// @generated from file hello_world/v1/greeter.proto (package hello_world.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";

/**
* @generated from message hello_world.v1.GreeterState
*/
export declare class GreeterState extends Message<GreeterState> {
/**
* @generated from field: repeated string greetings = 2;
*/
greetings: string[];

constructor(data?: PartialMessage<GreeterState>);

static readonly runtime: typeof proto3;
static readonly typeName = "hello_world.v1.GreeterState";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GreeterState;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GreeterState;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GreeterState;

static equals(a: GreeterState | PlainMessage<GreeterState> | undefined, b: GreeterState | PlainMessage<GreeterState> | undefined): boolean;
}

/**
* @generated from message hello_world.v1.GreetingsRequest
*/
export declare class GreetingsRequest extends Message<GreetingsRequest> {
constructor(data?: PartialMessage<GreetingsRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "hello_world.v1.GreetingsRequest";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GreetingsRequest;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GreetingsRequest;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GreetingsRequest;

static equals(a: GreetingsRequest | PlainMessage<GreetingsRequest> | undefined, b: GreetingsRequest | PlainMessage<GreetingsRequest> | undefined): boolean;
}

/**
* @generated from message hello_world.v1.GreetingsResponse
*/
export declare class GreetingsResponse extends Message<GreetingsResponse> {
/**
* @generated from field: repeated string greetings = 1;
*/
greetings: string[];

constructor(data?: PartialMessage<GreetingsResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "hello_world.v1.GreetingsResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GreetingsResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GreetingsResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GreetingsResponse;

static equals(a: GreetingsResponse | PlainMessage<GreetingsResponse> | undefined, b: GreetingsResponse | PlainMessage<GreetingsResponse> | undefined): boolean;
}

/**
* @generated from message hello_world.v1.GreetRequest
*/
export declare class GreetRequest extends Message<GreetRequest> {
/**
* E.g. "Hello, World".
*
* @generated from field: string greeting = 1;
*/
greeting: string;

constructor(data?: PartialMessage<GreetRequest>);

static readonly runtime: typeof proto3;
static readonly typeName = "hello_world.v1.GreetRequest";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GreetRequest;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GreetRequest;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GreetRequest;

static equals(a: GreetRequest | PlainMessage<GreetRequest> | undefined, b: GreetRequest | PlainMessage<GreetRequest> | undefined): boolean;
}

/**
* @generated from message hello_world.v1.GreetResponse
*/
export declare class GreetResponse extends Message<GreetResponse> {
/**
* @generated from field: string greeting = 1;
*/
greeting: string;

constructor(data?: PartialMessage<GreetResponse>);

static readonly runtime: typeof proto3;
static readonly typeName = "hello_world.v1.GreetResponse";
static readonly fields: FieldList;

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GreetResponse;

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GreetResponse;

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GreetResponse;

static equals(a: GreetResponse | PlainMessage<GreetResponse> | undefined, b: GreetResponse | PlainMessage<GreetResponse> | undefined): boolean;
}

55 changes: 55 additions & 0 deletions api/hello_world/v1/greeter_pb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// @generated by protoc-gen-es v1.3.1
// @generated from file hello_world/v1/greeter.proto (package hello_world.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import { proto3 } from "@bufbuild/protobuf";

/**
* @generated from message hello_world.v1.GreeterState
*/
export const GreeterState = proto3.makeMessageType(
"hello_world.v1.GreeterState",
() => [
{ no: 2, name: "greetings", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
],
);

/**
* @generated from message hello_world.v1.GreetingsRequest
*/
export const GreetingsRequest = proto3.makeMessageType(
"hello_world.v1.GreetingsRequest",
[],
);

/**
* @generated from message hello_world.v1.GreetingsResponse
*/
export const GreetingsResponse = proto3.makeMessageType(
"hello_world.v1.GreetingsResponse",
() => [
{ no: 1, name: "greetings", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
],
);

/**
* @generated from message hello_world.v1.GreetRequest
*/
export const GreetRequest = proto3.makeMessageType(
"hello_world.v1.GreetRequest",
() => [
{ no: 1, name: "greeting", kind: "scalar", T: 9 /* ScalarType.STRING */ },
],
);

/**
* @generated from message hello_world.v1.GreetResponse
*/
export const GreetResponse = proto3.makeMessageType(
"hello_world.v1.GreetResponse",
() => [
{ no: 1, name: "greeting", kind: "scalar", T: 9 /* ScalarType.STRING */ },
],
);

Loading

0 comments on commit 963d7a7

Please sign in to comment.