mkvirtualenv alembic_sample --python=/usr/local/bin/python3
pip install -r requirements.txt
Create a mysql database: todo
Configure migrations/env.py
to update the sqlalchemy.url
config if
the default config is different from your local setup.
alembic upgrade head
python todo_server.py
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. todo.proto
This is how clients connect to grpc and call rpc methods.
import grpc
import todo_pb2, todo_pb2_grpc
MAX_MESSAGE_LENGTH = 4 * 1024 * 1024 * 10
options = [
('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)
]
channel = grpc.insecure_channel(
'localhost:50051',
options=options,
)
stub = todo_pb2_grpc.TodoServiceStub(channel)
stub.GetUsers(todo_pb2.UsersRequest())
stub.GetUser(todo_pb2.User(id=1))
stub.GetUserTodos(todo_pb2.User(id=1))
stub.GetTodo(todo_pb2.Todo(id=3))
user_req = todo_pb2.User(name="abc", email="[email protected]")
user_resp = stub.CreateUser(user_req)
### CreateTodo