Skip to content

Commit b65db06

Browse files
author
bhupeshbhatia
committed
Initial commit
0 parents  commit b65db06

32 files changed

+2287
-0
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.history
2+
.vagrant
3+
.vscode
4+
vendor*

.env

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ===> Kafka
2+
KAFKA_BROKERS=kafka:9092
3+
4+
KAFKA_CONSUMER_EVENT_GROUP=agg.flashsale.query.event.1
5+
KAFKA_CONSUMER_EVENT_QUERY_GROUP=agg.flashsale.query.eq.1
6+
7+
KAFKA_CONSUMER_EVENT_TOPIC=event.persistence.response.7
8+
KAFKA_CONSUMER_EVENT_QUERY_TOPIC=esquery.response.7
9+
KAFKA_PRODUCER_EVENT_TOPIC=event.rns_eventstore.events
10+
KAFKA_PRODUCER_EVENT_QUERY_TOPIC=esquery.request
11+
KAFKA_PRODUCER_RESPONSE_TOPIC=agg.flashsale.response
12+
13+
# ===> Mongo
14+
MONGO_HOSTS=mongo:27017
15+
MONGO_USERNAME=root
16+
MONGO_PASSWORD=root
17+
18+
MONGO_DATABASE=rns_projections
19+
MONGO_AGG_COLLECTION=agg_flashsale
20+
MONGO_META_COLLECTION=aggregate_meta
21+
22+
MONGO_CONNECTION_TIMEOUT_MS=3000
23+
MONGO_RESOURCE_TIMEOUT_MS=5000

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.history
2+
.vscode
3+
vendor*
4+
debug*

.golangci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
linters:
2+
enable:
3+
- dupl
4+
- gocyclo
5+
- maligned
6+
- misspell
7+
- lll
8+
- unparam
9+
10+
linters-settings:
11+
errcheck:
12+
check-type-assertions: true
13+
check-blank: true
14+
lll:
15+
line-length: 90
16+
unparam:
17+
algo: rta

.goreleaser.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
project_name: agg-flashsalecap-query
2+
3+
builds:
4+
- main: ./main/
5+
env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
- windows
10+
11+
archive:
12+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
13+
format: binary
14+
15+
sign:
16+
artifacts: none
17+
18+
release:
19+
github:
20+
owner: TerrexTech
21+
name: agg-flashsalecap-query
22+
23+
changelog:
24+
sort: asc
25+
filters:
26+
exclude:
27+
- '^bors:'
28+
- '^docs:'
29+
- typo
30+
31+
dockers:
32+
- image: terrextech/agg-flashsalecap-query
33+
binary: agg-flashsalecap-query
34+
dockerfile: Dockerfile_ci
35+
goos: linux
36+
goarch: amd64
37+
tag_templates:
38+
- "{{ .Tag }}"
39+
- latest
40+
extra_files:
41+
- .env

.travis.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
dist: trusty
2+
3+
services:
4+
- docker
5+
6+
language: go
7+
8+
go:
9+
- "1.11"
10+
11+
# Only clone the most recent commit
12+
git:
13+
depth: 1
14+
15+
branches:
16+
except:
17+
- staging.tmp
18+
19+
env:
20+
global:
21+
- DEP_VERSION="0.5.0"
22+
- DOCKER_COMPOSE_VERSION=1.22.0
23+
24+
addons:
25+
apt:
26+
packages:
27+
- docker-ce
28+
29+
before_install:
30+
# Download dep binary to $GOPATH/bin
31+
- if [[ ! -z ${TRAVIS_TAG} ]]; then
32+
curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep &&
33+
chmod +x $GOPATH/bin/dep;
34+
fi
35+
36+
# Docker-Compose
37+
- sudo rm /usr/local/bin/docker-compose
38+
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname
39+
-s`-`uname -m` > docker-compose
40+
- chmod +x docker-compose
41+
- sudo mv docker-compose /usr/local/bin
42+
43+
install:
44+
# Only install local deps if its a tagged-commit
45+
- if [[ ! -z ${TRAVIS_TAG} ]]; then dep ensure; fi
46+
47+
before_script:
48+
- chmod +x ./run_test.sh
49+
50+
script:
51+
- ./run_test.sh
52+
53+
after_script:
54+
- docker-compose -f ./test/docker-compose.yaml down --volumes --rmi all
55+
56+
after_success:
57+
- test -n "$TRAVIS_TAG"
58+
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
59+
60+
deploy:
61+
- provider: script
62+
skip_cleanup: true
63+
script: curl -sL https://git.io/goreleaser | bash -s -- --debug --skip-validate
64+
on:
65+
all_branches: true
66+
tags: true

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ===> Build Image
2+
FROM golang:1.11.0-alpine3.8 AS builder
3+
LABEL maintainer="Jaskaranbir Dhillon"
4+
5+
ARG SOURCE_REPO
6+
7+
ENV DEP_VERSION=0.5.0 \
8+
CGO_ENABLED=0 \
9+
GOOS=linux
10+
11+
# Download and install dep and git
12+
ADD https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 /usr/bin/dep
13+
RUN chmod +x /usr/bin/dep
14+
RUN apk add --update git
15+
16+
WORKDIR $GOPATH/src/github.com/TerrexTech/${SOURCE_REPO}
17+
18+
# Copy the code from the host and compile it
19+
COPY Gopkg.toml Gopkg.lock ./
20+
RUN dep ensure --vendor-only -v
21+
COPY . ./
22+
23+
RUN go build -v -a -installsuffix nocgo -o /app ./main
24+
25+
# ===> Run Image
26+
FROM scratch
27+
LABEL maintainer="Jaskaranbir Dhillon"
28+
29+
COPY --from=builder /app ./
30+
ENTRYPOINT ["./app"]

Dockerfile_ci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Dockerfile used by GoReleaser
2+
FROM scratch
3+
LABEL maintainer="Jaskaranbir Dhillon"
4+
5+
COPY /agg-flashsalecap-query ./
6+
ENTRYPOINT ["./agg-flashsalecap-query"]

Dockerfile_test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dockerfile for building base image for tests
2+
FROM golang:1.11.0-alpine3.8
3+
LABEL maintainer="Jaskaranbir Dhillon"
4+
5+
ARG SOURCE_REPO
6+
7+
ENV DEP_VERSION=0.5.0
8+
9+
# Download and install dep and git
10+
ADD https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 /usr/bin/dep
11+
RUN chmod +x /usr/bin/dep
12+
RUN apk add --update git
13+
14+
WORKDIR $GOPATH/src/github.com/TerrexTech/${SOURCE_REPO}
15+
16+
# Copy the code from the host and compile it
17+
COPY Gopkg.toml Gopkg.lock ./
18+
RUN dep ensure --vendor-only -v
19+
20+
COPY . ./
21+
22+
CMD go run main/*.go

0 commit comments

Comments
 (0)