Skip to content

Commit

Permalink
Add README, CHANGES, tweak command line flags (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
klingerf authored May 15, 2017
1 parent 11969f2 commit 3b6046c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

First release 🎈
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# strest-grpc

Strest client and server implementations for gRPC.

## Running Locally

To run the client and server locally, first start the server.

```
$ go run server/main.go
starting gRPC server on :11111
```

Next run the client. By default, the client will send as many request as it can
on a single connection for 10 seconds, and exit with a performance report.

```
$ go run client/main.go --address localhost:11111
2017-05-12T16:17:40-07:00 98.2KB 354/0 10s L: 0 [ 89 97 ] 102 J: 0 0
{
"good": 354,
"bad": 0,
"bytes": 100556,
"latency": {
"50": 10,
"95": 89,
"99": 97,
"999": 102
},
"jitter": {
"50": 0,
"95": 0,
"99": 0,
"999": 0
}
}
```

### Flags

Use the `-help` flag with either the client or server to see a list of flags.

## Building

To build the client and server binaries, run:

```
./bin/release.sh
```

That will create `strest-client-linux` and `strest-server-linux` binaries in the
root of the project.

To build a docker image, run:

```
$ docker build -t buoyantio/strest-grpc:latest .
```

Replace `latest` with whatever tag you are trying to build.

## Releasing

To release:

* Update and submit a PR with a changelog for the release in [CHANGES.md](CHANGES.md).
* Merge the changelog PR.
* Build the client and server binaries as described in the [Building](#building) section above.
* Use Github to [create a new release](https://github.com/BuoyantIO/strest-grpc/releases/new).
* Add the binaries that you built as attachments to the release.
* The docker image is built automatically once the release is created.
6 changes: 1 addition & 5 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,17 +452,13 @@ func main() {
latencyHist.Reset()
jitterHist.Reset()
timeout = time.After(*interval)
if totalCount > 0 && totalCount > *totalRequests {
if *totalRequests > 0 && totalCount > *totalRequests {
cleanup <- struct{}{}
}
}
}
}()

wg.Wait()

if !*disableFinalReport {
logFinalReport(totalGood, totalBad, totalBytes, globalLatencyHist, globalJitterHist)
}
os.Exit(0)
}
17 changes: 7 additions & 10 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"google.golang.org/grpc"
)

const port = ":11111"

type server struct{}

var (
Expand Down Expand Up @@ -138,7 +136,9 @@ func (s *server) StreamingGet(stream pb.Responder_StreamingGetServer) error {
}

func main() {
help := flag.Bool("help", false, "show help message")
rand.Seed(time.Now().UnixNano())

address := flag.String("address", ":11111", "hostname:port to serve on")
metricAddr := flag.String("metric-addr", "", "address to serve metrics on")

flag.Usage = func() {
Expand All @@ -148,20 +148,17 @@ func main() {

flag.Parse()

if *help {
flag.Usage()
os.Exit(64)
}

if *metricAddr != "" {
registerMetrics()
go func() {
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(*metricAddr, nil)
}()
}
rand.Seed(time.Now().UnixNano())
lis, err := net.Listen("tcp", port)

fmt.Println("starting gRPC server on", *address)

lis, err := net.Listen("tcp", *address)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
Expand Down

0 comments on commit 3b6046c

Please sign in to comment.