Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLuo committed May 13, 2017
1 parent 72a378a commit a92cc0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@ $ pip install grpc-pytools
Generate a more Pythonic service for the gRPC service defined in the xx_pb2.py file (generated by `grpcio-tools`):

```bash
$ python -mgrpc_tools.pythonic --pb2-module-name='python.path.xx_pb2'
$ python -m grpc_tools.pythonic --pb2-module-name='python.path.xx_pb2'
```

### Marshmallow schemas

Generate [marshmallow][2] schemas for all gRPC messages defined in the xx_pb2.py file:

```bash
$ python -mgrpc_tools.marshmallow --pb2-module-name='python.path.xx_pb2'
$ python -m grpc_tools.marshmallow --pb2-module-name='python.path.xx_pb2'
```

### RESTArt APIs

Generate simple [RESTArt][3] APIs for all gRPC methods defined in the xx_pb2.py file:

```bash
$ python -mgrpc_pytools.restart --pb2-module-name='python.path.xx_pb2' --grpc-server='localhost:50051'
$ python -m grpc_pytools.restart --pb2-module-name='python.path.xx_pb2' --grpc-server='localhost:50051'
```


## Examples

See [examples](examples) to find out how to generate a simple JSON API proxy.
See [examples](examples) to find out how to generate a simple JSON proxy for a gRPC service.


## License
Expand Down
12 changes: 6 additions & 6 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

First of all, change to directory `helloworld`.

### Generate the JSON API proxy
### Generate the JSON proxy

1. Generate the helloworld_pb2.py file

Expand All @@ -15,19 +15,19 @@ First of all, change to directory `helloworld`.
2. Generate the Pythonic service

```bash
$ python -mgrpc_pytools.pythonic --pb2-module-name='helloworld_pb2' --service-name='Greeter' > service.py
$ python -m grpc_pytools.pythonic --pb2-module-name='helloworld_pb2' --service-name='Greeter' > service.py
```

3. Generate the marshmallow schemas

```bash
$ python -mgrpc_pytools.marshmallow --pb2-module-name='helloworld_pb2' > schemas.py
$ python -m grpc_pytools.marshmallow --pb2-module-name='helloworld_pb2' > schemas.py
```

4. Generate the RESTArt APIs

```bash
$ python -mgrpc_pytools.restart --pb2-module-name='helloworld_pb2' --grpc-server='localhost:50051' --service-name='Greeter' > apis.py
$ python -m grpc_pytools.restart --pb2-module-name='helloworld_pb2' --grpc-server='localhost:50051' --service-name='Greeter' > apis.py
```

Simplify all the above steps by `make`:
Expand All @@ -42,13 +42,13 @@ $ make
$ python greeter_server.py
```

### Start the JSON API proxy
### Start the JSON proxy

```bash
$ restart apis:api -p 6666
```

### Consume JSON APIs
### Consume the JSON APIs

```bash
# By cURL
Expand Down
6 changes: 3 additions & 3 deletions examples/helloworld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ all: gen

gen:
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. helloworld.proto
python -mgrpc_pytools.pythonic --pb2-module-name='helloworld_pb2' --service-name='Greeter' > service.py
python -mgrpc_pytools.marshmallow --pb2-module-name='helloworld_pb2' > schemas.py
python -mgrpc_pytools.restart --pb2-module-name='helloworld_pb2' --grpc-server='localhost:50051' --service-name='Greeter' > apis.py
python -m grpc_pytools.pythonic --pb2-module-name='helloworld_pb2' --service-name='Greeter' > service.py
python -m grpc_pytools.marshmallow --pb2-module-name='helloworld_pb2' > schemas.py
python -m grpc_pytools.restart --pb2-module-name='helloworld_pb2' --grpc-server='localhost:50051' --service-name='Greeter' > apis.py

0 comments on commit a92cc0d

Please sign in to comment.