Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #7 from uber/example
Browse files Browse the repository at this point in the history
Make host:port configurable from command line
  • Loading branch information
thuningxu authored Jan 23, 2017
2 parents 4277877 + 425a82d commit dcf9c0f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions example.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package main

import (
"flag"
"fmt"
"os"
"runtime/debug"
Expand All @@ -29,12 +30,10 @@ import (
cthrift "github.com/uber/cherami-thrift/.generated/go/cherami"
"github.com/uber/cherami-client-go/client/cherami"
"github.com/apache/thrift/lib/go/thrift"
"github.com/uber/tchannel-go"
)

const (
port = 4922 // cherami-frontend running on this port by default
)
var host = flag.String("host", "127.0.0.1", "cherami-frontend host IP")
var port = flag.Int("port", 4922, "cherami-frontend port")

// helper function to print out a thrift object in json
func jsonify(obj thrift.TStruct) string {
Expand All @@ -55,12 +54,11 @@ func exitIfError(err error) {
}

func main() {
// get the IP address of the interface
host, _ := tchannel.ListenIP()
flag.Parse()

// First, create the client to interact with Cherami
// Here we directly connect to cherami running on host:port
cClient, err := cherami.NewClient("cherami-example", host.String(), port, &cherami.ClientOptions{
cClient, err := cherami.NewClient("cherami-example", *host, *port, &cherami.ClientOptions{
Timeout: time.Minute,
})
exitIfError(err)
Expand Down

0 comments on commit dcf9c0f

Please sign in to comment.