Unverified Commit c34a64a0 authored by Christina Delimitrou's avatar Christina Delimitrou Committed by GitHub

Merge pull request #17 from zyqCSL/master

Adding hotel reservation service
parents b7ed2383 1a40c539
cmd/*/data
cmd/api/api
cmd/auth/auth
cmd/geo/geo
cmd/profile/profile
cmd/rate/rate
cmd/www/www
cmd/search/search
FROM golang:1.9
COPY . /go/src/github.com/harlow/go-micro-services
WORKDIR /go/src/github.com/harlow/go-micro-services
RUN go get gopkg.in/mgo.v2
RUN go get github.com/bradfitz/gomemcache/memcache
RUN go install -ldflags="-s -w" ./cmd/...
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/apache/thrift"
packages = ["lib/go/thrift"]
revision = "b2a4d4ae21c789b689dd162deb819665567f481c"
version = "0.10.0"
[[projects]]
branch = "master"
name = "github.com/codahale/hdrhistogram"
packages = ["."]
revision = "3a0bb77429bd3a61596f5e8a3172445844342120"
[[projects]]
name = "github.com/golang/protobuf"
packages = [
"proto",
"ptypes",
"ptypes/any",
"ptypes/duration",
"ptypes/timestamp"
]
revision = "925541529c1fa6821df4e44ce2723319eb2be768"
version = "v1.0.0"
[[projects]]
branch = "master"
name = "github.com/grpc-ecosystem/grpc-opentracing"
packages = ["go/otgrpc"]
revision = "0e7658f8ee99ee5aa683e2a032b8880091b7a055"
[[projects]]
branch = "master"
name = "github.com/hailocab/go-geoindex"
packages = ["."]
revision = "64631bfe9711db743898df0295316784c876d29c"
[[projects]]
name = "github.com/hashicorp/consul"
packages = ["api"]
revision = "9a494b5fb9c86180a5702e29c485df1507a47198"
version = "v1.0.6"
[[projects]]
branch = "master"
name = "github.com/hashicorp/go-cleanhttp"
packages = ["."]
revision = "d5fe4b57a186c716b0e00b8c301cbd9b4182694d"
[[projects]]
branch = "master"
name = "github.com/hashicorp/go-rootcerts"
packages = ["."]
revision = "6bb64b370b90e7ef1fa532be9e591a81c3493e00"
[[projects]]
name = "github.com/hashicorp/serf"
packages = ["coordinate"]
revision = "d6574a5bb1226678d7010325fb6c985db20ee458"
version = "v0.8.1"
[[projects]]
branch = "master"
name = "github.com/mitchellh/go-homedir"
packages = ["."]
revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
[[projects]]
name = "github.com/olivere/grpc"
packages = ["lb/consul"]
revision = "fec704fef18da7cd0da77c6840bed0b25b07d570"
version = "v1.0.0"
[[projects]]
branch = "master"
name = "github.com/opentracing-contrib/go-stdlib"
packages = ["nethttp"]
revision = "f6b9967a3c699b16f941872d6115b2860915bd5b"
[[projects]]
name = "github.com/opentracing/opentracing-go"
packages = [
".",
"ext",
"log"
]
revision = "1949ddbfd147afd4d964a9f00b24eb291e0e7c38"
version = "v1.0.2"
[[projects]]
name = "github.com/uber/jaeger-client-go"
packages = [
".",
"config",
"internal/baggage",
"internal/baggage/remote",
"internal/spanlog",
"log",
"rpcmetrics",
"thrift-gen/agent",
"thrift-gen/baggage",
"thrift-gen/jaeger",
"thrift-gen/sampling",
"thrift-gen/zipkincore",
"utils"
]
revision = "3ac96c6e679cb60a74589b0d0aa7c70a906183f7"
version = "v2.11.2"
[[projects]]
name = "github.com/uber/jaeger-lib"
packages = ["metrics"]
revision = "4267858c0679cd4e47cefed8d7f70fd386cfb567"
version = "v1.4.0"
[[projects]]
branch = "master"
name = "golang.org/x/net"
packages = [
"context",
"http2",
"http2/hpack",
"idna",
"internal/timeseries",
"lex/httplex",
"trace"
]
revision = "07e8617a6db2368fa55d4616f371ee1b1403c817"
[[projects]]
name = "golang.org/x/text"
packages = [
"collate",
"collate/build",
"internal/colltab",
"internal/gen",
"internal/tag",
"internal/triegen",
"internal/ucd",
"language",
"secure/bidirule",
"transform",
"unicode/bidi",
"unicode/cldr",
"unicode/norm",
"unicode/rangetable"
]
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
branch = "master"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
revision = "df60624c1e9b9d2973e889c7a1cff73155da81c4"
[[projects]]
name = "google.golang.org/grpc"
packages = [
".",
"balancer",
"balancer/base",
"balancer/roundrobin",
"codes",
"connectivity",
"credentials",
"encoding",
"encoding/proto",
"grpclb/grpc_lb_v1/messages",
"grpclog",
"internal",
"keepalive",
"metadata",
"naming",
"peer",
"resolver",
"resolver/dns",
"resolver/passthrough",
"stats",
"status",
"tap",
"transport"
]
revision = "8e4536a86ab602859c20df5ebfd0bd4228d08655"
version = "v1.10.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "d6e37e604116f8edd7366fc8611caf6f8bf54e30de7c5c3efe3a87c232ffa3b3"
solver-name = "gps-cdcl"
solver-version = 1
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
name = "github.com/golang/protobuf"
version = "1.0.0"
[[constraint]]
branch = "master"
name = "github.com/hailocab/go-geoindex"
[[constraint]]
name = "github.com/opentracing/opentracing-go"
version = "1.0.2"
[[constraint]]
name = "github.com/uber/jaeger-client-go"
version = "2.11.2"
[[constraint]]
name = "github.com/uber/jaeger-lib"
version = "1.4.0"
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
name = "google.golang.org/grpc"
version = "1.10.0"
[prune]
go-tests = true
unused-packages = true
.PHONY: proto data run
proto:
for f in services/**/proto/*.proto; do \
protoc --go_out=plugins=grpc:. $$f; \
echo compiled: $$f; \
done
data:
go-bindata -o data/bindata.go -pkg data data/*.json
run:
docker-compose build
docker-compose up --remove-orphans
# Hotel Reservation
A hotel reservation microservice, built with Go and gRPC, based on https://github.com/harlow/go-micro-services.
<!-- ## Application Structure -->
<!-- ![Social Network Architecture](socialNet_arch.png) -->
Supported actions:
* Get profile and rates of nearby hotels available during given time periods
* Recommend hotels based on user provided metrics
* Place reservations
## Pre-requirements
- Docker
- Docker-compose
- luarocks (apt-get install luarocks)
- luasocket (luarocks install luasocket)
## Running the social network application
### Before you start
- Install Docker and Docker Compose.
- Make sure exposed ports in docker-compose files are available
- Replace x.x.x.x in config.json with ip address of your servers
### Start docker containers
Start docker containers by running `docker-compose up -d`. All images will be
pulled from Docker Hub.
#### workload generation
```bash
$WRK_DIR/wrk -D exp -t <num-threads> -c <num-conns> -d <duration> -L -s ./wrk2_lua_scripts/mixed-workload_type_1.lua http://x.x.x.x:5000 -R <reqs-per-sec>
```
### Questions and contact
You are welcome to submit a pull request if you find a bug or have extended the application in an interesting way. For any questions please contact us at: <microservices-bench-L@list.cornell.edu>
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"strconv"
"github.com/harlow/go-micro-services/registry"
"github.com/harlow/go-micro-services/services/frontend"
"github.com/harlow/go-micro-services/tracing"
)
func main() {
jsonFile, err := os.Open("config.json")
if err != nil {
fmt.Println(err)
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
var result map[string]string
json.Unmarshal([]byte(byteValue), &result)
serv_port, _ := strconv.Atoi(result["FrontendPort"])
serv_ip := result["FrontendIP"]
fmt.Printf("frontend ip = %s, port = %d\n", serv_ip, serv_port)
var (
// port = flag.Int("port", 5000, "The server port")
jaegeraddr = flag.String("jaegeraddr", result["jaegerAddress"], "Jaeger address")
consuladdr = flag.String("consuladdr", result["consulAddress"], "Consul address")
)
flag.Parse()
tracer, err := tracing.Init("frontend", *jaegeraddr)
if err != nil {
panic(err)
}
registry, err := registry.NewClient(*consuladdr)
if err != nil {
panic(err)
}
srv := &frontend.Server{
Registry: registry,
Tracer: tracer,
IpAddr: serv_ip,
Port: serv_port,
}
log.Fatal(srv.Run())
}
package main
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"log"
"strconv"
"fmt"
)
type point struct {