-
Notifications
You must be signed in to change notification settings - Fork 4
/
application.go
76 lines (68 loc) · 2.09 KB
/
application.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package mahi
import (
"context"
"time"
)
var (
AvailableStorageEngines = []string{
StorageEngineWasabi,
StorageEngineDigitalOcean,
StorageEngineS3,
StorageEngineB2,
StorageEngineAzureBlob,
}
)
const (
StorageEngineWasabi = "wasabi"
StorageEngineDigitalOcean = "digital_ocean"
StorageEngineS3 = "s3"
StorageEngineB2 = "b2"
StorageEngineAzureBlob = "azure_blob"
)
// ApplicationService defines the business logic for dealing with all aspects of an application.
type ApplicationService interface {
Create(ctx context.Context, n *NewApplication) (*Application, error)
Application(ctx context.Context, id string) (*Application, error)
Applications(ctx context.Context, sinceID string, limit int) ([]*Application, error)
Delete(ctx context.Context, id string) error
Update(ctx context.Context, u *UpdateApplication) (*Application, error)
FileBlobStorage(engine, accessKey, secretKey, region, endpoint string) (FileBlobStorage, error)
}
// ApplicationStorage handles communication with the database for handling applications.
type ApplicationStorage interface {
Store(ctx context.Context, n *NewApplication) (*Application, error)
Application(ctx context.Context, id string) (*Application, error)
Applications(ctx context.Context, sinceID string, limit int) ([]*Application, error)
Delete(ctx context.Context, id string) error
Update(ctx context.Context, u *UpdateApplication) (*Application, error)
}
type Application struct {
ID string
Name string
Description string
StorageAccessKey string
StorageSecretKey string
StorageBucket string
StorageEndpoint string
StorageRegion string
StorageEngine string
DeliveryURL string
CreatedAt time.Time
UpdatedAt time.Time
}
type UpdateApplication struct {
ID string
Name string
Description string
}
type NewApplication struct {
Name string
Description string
StorageAccessKey string
StorageSecretKey string
StorageBucket string
StorageEndpoint string
StorageRegion string
StorageEngine string
DeliveryURL string
}