This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker: | |
- image: synqfm/circleci:0.1.5 | |
- image: library/postgres:9.6.3 | |
environment: | |
POSTGRES_DB: gosample_test | |
POSTGRES_USER: circleci | |
POSTGRES_PASSWORD: circleci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM circleci/golang:1.8.1 | |
COPY *.list /etc/apt/sources.list.d/ | |
RUN sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 | |
RUN sudo apt update | |
RUN sudo apt install -y \ | |
ansible \ | |
postgresql-client \ | |
python3-pip \ | |
ffmpeg \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- run: | |
name: Waiting for Postgres to be ready | |
command: | | |
for i in `seq 1 10`; | |
do | |
psql -h localhost -U $PG_USER $PG_DB -c "\t" && echo DB Up && exit 0 | |
echo -n . | |
sleep 1 | |
done | |
echo Failed waiting for Postgres && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- run: | |
name: Run Golang Tests | |
command: | | |
GOPATH=$GOPATH:"${SYNQ_DIR}"/"${REPO}"/vendor overalls -project=github.com/SYNQfm/"${REPO}" -covermode=atomic -debug -ignore=.git,.github,.circleci,vendor,sql,sample -- -race -v | |
if [ -z ${COVERALLS_TOKEN} ]; then | |
echo "coveralls token isn't set, skipping" | |
else | |
goveralls -coverprofile="${SYNQ_DIR}"/"${REPO}"/overalls.coverprofile -service circle-ci -repotoken "${COVERALLS_TOKEN}" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"flyway": { | |
"password": "supersecret" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ApiCall struct { | |
Id int64 `db:"id" json:"id"` | |
Type string `db:"type" json:"type"` | |
CreatedAt time.Time `db:"ctime" json:"-"` | |
Called time.Time `db:"called" json:"called"` | |
VideoId string `db:"video_id" json:"video_id"` | |
Taken time.Duration `db:"taken" json:"taken"` | |
Error string `db:"error" json:"error"` | |
Video synq.Video `db:"result" json:"video"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (a *ApiCall) Call() error { | |
defer a.Save() | |
start := time.Now() | |
video, err := sApi.GetVideo(a.VideoId) | |
a.Taken = time.Since(start) | |
if err != nil { | |
a.Error = err.Error() | |
return err | |
} | |
a.Type = "/v1/video/details" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will just get the video id and call the Synq api for the details | |
func details(c *gin.Context) { | |
a := ApiCall{} | |
c.BindJSON(&a) | |
if a.VideoId == "" { | |
c.JSON(400, gin.H{ | |
"message": "missing 'video_id'", | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupRouter(port string) { | |
router := gin.Default() | |
v1 := router.Group("/v1") | |
{ | |
v1.POST("/details", details) | |
v1.GET("/status", status) | |
} | |
log.Println("Running server on port :", port) | |
serverStarted = time.Now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (v Video) Value() (driver.Value, error) { | |
json, err := json.Marshal(v) | |
return json, err | |
} | |
func (v *Video) Scan(src interface{}) error { | |
source, ok := src.([]byte) | |
if !ok { | |
return errors.New("Type assertion .([]byte) failed.") | |
} |
OlderNewer