Skip to content

Commit 8e9277e

Browse files
authored
Merge pull request tokopedia#112 from tokopedia/add_diagram_in_readme
Add diagram in readme
2 parents 806becc + c4987b3 commit 8e9277e

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

Readme.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@ The server implementation is in GoLang but the client can be any programming lan
55

66
---
77

8-
### Announcement:
9-
The latest [version (v1.10)](https://github.com/tokopedia/gripmock/releases/tag/v1.10) of gripmock is requiring `go_package` declaration in the `.proto` file. This is due to the latest update of `protoc` plugin that being used by gripmock is making the `go_package` declaration mandatory.
10-
11-
**Update Feb 2022:**
8+
## Quick Usage
9+
First, prepare your `.proto` file. Or you can use `hello.proto` in `example/simple/` folder. Suppose you put it in `/mypath/hello.proto`. We are gonna use Docker image for easier example test.
10+
basic syntax to run GripMock is
11+
`gripmock <protofile>`
1212

13-
[Version 1.11-beta](https://github.com/tokopedia/gripmock/releases/tag/v1.11-beta) release is available.
14-
It supports **NO** declaration of `go_package`, please download and test before it can be tagged as stable.
13+
- Install [Docker](https://docs.docker.com/install/)
14+
- Run `docker pull tkpd/gripmock` to pull the image
15+
- We are gonna mount `/mypath/hello.proto` (it must be a fullpath) into a container and also we expose ports needed. Run `docker run -p 4770:4770 -p 4771:4771 -v /mypath:/proto tkpd/gripmock /proto/hello.proto`
16+
- On a separate terminal we are gonna add a stub into the stub service. Run `curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add `
17+
- Now we are ready to test it with our client. You can find a client example file under `example/simple/client/`. Execute one of your preferred language. Example for go: `go run example/simple/client/go/*.go`
1518

16-
you can get the docker image using `docker pull tkpd/gripmock:v1.11-beta`.
19+
Check [`example`](https://github.com/tokopedia/gripmock/tree/master/example) folder for various usecase of gripmock.
1720

1821
---
1922

2023
## How It Works
21-
GripMock has 2 main components:
24+
![Running Gripmock](/assets/images/gripmock_readme-running%20system.png)
25+
26+
From client perspective, GripMock has 2 main components:
2227
1. GRPC server that serves on `tcp://localhost:4770`. Its main job is to serve incoming rpc call from client and then parse the input so that it can be posted to Stub service to find the perfect stub match.
2328
2. Stub server that serves on `http://localhost:4771`. Its main job is to store all the stub mapping. We can add a new stub or list existing stub using http request.
2429

2530
Matched stub will be returned to GRPC service then further parse it to response the rpc call.
2631

27-
## Quick Usage
28-
First, prepare your `.proto` file. Or you can use `hello.proto` in `example/simple/` folder. Suppose you put it in `/mypath/hello.proto`. We are gonna use Docker image for easier example test.
29-
basic syntax to run GripMock is
30-
`gripmock <protofile>`
3132

32-
- Install [Docker](https://docs.docker.com/install/)
33-
- Run `docker pull tkpd/gripmock` to pull the image
34-
- We are gonna mount `/mypath/hello.proto` (it must be a fullpath) into a container and also we expose ports needed. Run `docker run -p 4770:4770 -p 4771:4771 -v /mypath:/proto tkpd/gripmock /proto/hello.proto`
35-
- On a separate terminal we are gonna add a stub into the stub service. Run `curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add `
36-
- Now we are ready to test it with our client. You can find a client example file under `example/simple/client/`. Execute one of your preferred language. Example for go: `go run example/simple/client/go/*.go`
33+
From technical perspective, GripMock consists of 2 binaries.
34+
The first binary is the gripmock itself, when it will generate the gRPC server using the plugin installed in the system (see [Dockerfile](Dockerfile)).
35+
When the server sucessfully generated, it will be invoked in parallel with stub server which ends up opening 2 ports for client to use.
3736

38-
Check [`example`](https://github.com/tokopedia/gripmock/tree/master/example) folder for various usecase of gripmock.
37+
The second binary is the protoc plugin which located in folder [protoc-gen-gripmock](/protoc-gen-gripmock). This plugin is the one who translates protobuf declaration into a gRPC server in Go programming language.
38+
39+
![Inside GripMock](/assets/images/gripmock_readme-inside.png)
40+
41+
---
3942

4043
## Stubbing
4144

43.8 KB
Loading
23.4 KB
Loading

0 commit comments

Comments
 (0)