-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
59 lines (50 loc) · 1.37 KB
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package controllers
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/dgraph-io/badger"
"github.com/google/uuid"
)
var TableName = "Videos"
func GenerateUniqueVideoId(uid string) string {
id := uuid.NewString()
return id
}
type SessionController struct {
db *dynamodb.DynamoDB
cache *badger.DB
s3 *s3.S3
}
func NewSessionController(db *dynamodb.DynamoDB, cache *badger.DB, s3 *s3.S3) *SessionController {
return &SessionController{db, cache, s3}
}
func (sc SessionController) CreateVideosTable() error {
_, err := sc.db.CreateTable(&dynamodb.CreateTableInput{
AttributeDefinitions: []*dynamodb.AttributeDefinition{
{
AttributeName: aws.String("VID"),
AttributeType: aws.String("S"),
},
// {
// AttributeName: aws.String("Timestamp"),
// AttributeType: aws.String("N"),
// },
},
KeySchema: []*dynamodb.KeySchemaElement{
{
AttributeName: aws.String("VID"),
KeyType: aws.String("HASH"),
},
// {
// AttributeName: aws.String("Timestamp"),
// KeyType: aws.String("RANGE"),
// },
},
BillingMode: aws.String(dynamodb.BillingModePayPerRequest),
TableName: &TableName,
})
return err
}
// func (sc SessionController) CreateRawVideosBuckets() error {
// func (sc SessionController) CreateFinalVideosBuckets() error {