-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added call room endpoint + deploy updates
- Loading branch information
Showing
15 changed files
with
299 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
#!/bin/bash | ||
source ./env.cloud.sh | ||
cd .. | ||
gcloud functions deploy ScheduleCall \ | ||
--runtime go113 \ | ||
--allow-unauthenticated \ | ||
--trigger-http \ | ||
--project $GC_PROJECT \ | ||
--set-env-vars PG_PROTO=$PG_PROTO,PG_ADDR=$PG_ADDR,PG_DB=$PG_DB,PG_USER=$PG_USER,PG_PASSWORD=$PG_PASSWORD,GC_PROJECT=$GC_PROJECT,GC_PROJECT_LOCATION=$GC_PROJECT_LOCATION \ | ||
--region $GC_PROJECT_LOCATION \ | ||
--memory 128MB \ | ||
--max-instances 10 | ||
cd cmd | ||
source ./deploy.call.room.sh | ||
source ./deploy.schedule.call.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
source ./env.cloud.sh | ||
cd .. | ||
gcloud functions deploy CallRoom \ | ||
--runtime go113 \ | ||
--allow-unauthenticated \ | ||
--trigger-http \ | ||
--project $GC_PROJECT \ | ||
--set-env-vars PG_PROTO=$PG_PROTO,PG_ADDR=$PG_ADDR,PG_DB=$PG_DB,PG_USER=$PG_USER,PG_PASSWORD=$PG_PASSWORD,GC_PROJECT=$GC_PROJECT,GC_PROJECT_LOCATION=$GC_PROJECT_LOCATION,CALL_ROOM_ENDPOINT=$CALL_ROOM_ENDPOINT,SCHEDULER_LOCATION=$SCHEDULER_LOCATION,SCHEDULER_TIMEZONE=$SCHEDULER_TIMEZONE,CALL_ENDPOINT=$CALL_ENDPOINT,SCHEDULER_MAX_RETRY_COUNT=$SCHEDULER_MAX_RETRY_COUNT,SCHEDULER_RETRY_PERIOD=$SCHEDULER_RETRY_PERIOD \ | ||
--region $GC_PROJECT_LOCATION \ | ||
--memory 128MB \ | ||
--max-instances 10 | ||
cd cmd |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
source ./env.cloud.sh | ||
cd .. | ||
gcloud functions deploy ScheduleCall \ | ||
--runtime go113 \ | ||
--allow-unauthenticated \ | ||
--trigger-http \ | ||
--project $GC_PROJECT \ | ||
--set-env-vars PG_PROTO=$PG_PROTO,PG_ADDR=$PG_ADDR,PG_DB=$PG_DB,PG_USER=$PG_USER,PG_PASSWORD=$PG_PASSWORD,GC_PROJECT=$GC_PROJECT,GC_PROJECT_LOCATION=$GC_PROJECT_LOCATION,CALL_ROOM_ENDPOINT=$CALL_ROOM_ENDPOINT,SCHEDULER_LOCATION=$SCHEDULER_LOCATION,SCHEDULER_TIMEZONE=$SCHEDULER_TIMEZONE,CALL_ENDPOINT=$CALL_ENDPOINT,SCHEDULER_MAX_RETRY_COUNT=$SCHEDULER_MAX_RETRY_COUNT,SCHEDULER_RETRY_PERIOD=$SCHEDULER_RETRY_PERIOD \ | ||
--region $GC_PROJECT_LOCATION \ | ||
--memory 128MB \ | ||
--max-instances 10 | ||
cd cmd |
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package db | ||
|
||
import ( | ||
"github.com/evt/video8/model" | ||
) | ||
|
||
// SaveCall saves a call in Postgres | ||
func (db *PgDB) SaveCall(call *model.Call) error { | ||
_, err := db.Model(call).Returning("*").Insert() | ||
return err | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package migrations | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-pg/migrations/v7" | ||
) | ||
|
||
func init() { | ||
migrations.MustRegisterTx(func(db migrations.DB) error { | ||
fmt.Println("creating table calls...") | ||
_, err := db.Exec(`CREATE TABLE calls( | ||
call_id serial not null primary key, | ||
room_number integer not null, | ||
call_status integer not null, | ||
created timestamp default current_timestamp | ||
)`) | ||
return err | ||
}, func(db migrations.DB) error { | ||
fmt.Println("dropping table calls...") | ||
_, err := db.Exec(`DROP TABLE calls`) | ||
return err | ||
}) | ||
} |
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package model | ||
|
||
import "time" | ||
|
||
// CallRoomRequest is a request coming from google cloud scheduler to call rooms | ||
type CallRoomRequest struct { | ||
callTime string `json:"call_time"` | ||
} | ||
|
||
// Call is a room call that we save in Postgres at the moment room is called to know when it happened and what call status was | ||
type Call struct { | ||
tableName struct{} `pg:"calls"` | ||
CallID int `json:"call_id" pg:"call_id,notnull,pk"` | ||
RoomNumber int `json:"room_number" pg:"room_number,notnull"` | ||
CallStatus int `json:"call_status" pg:"call_status,notnull"` | ||
Created time.Time `json:"created" pg:"created"` | ||
} |
Oops, something went wrong.