/
config.go
65 lines (56 loc) · 1.98 KB
/
config.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
package configs
import (
"context"
"github.com/KejawenLab/bima/v3/messengers"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/olivere/elastic/v7"
"google.golang.org/grpc"
"gorm.io/gorm"
)
var Database *gorm.DB
type (
Server interface {
Register(server *grpc.Server)
Handle(context context.Context, server *runtime.ServeMux, client *grpc.ClientConn) error
Migrate(db *gorm.DB)
Consume(messenger *messengers.Messenger)
Sync(client *elastic.Client)
}
Service struct {
Name string `json:"name" yaml:"name"`
ConnonicalName string
}
Db struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
User string `json:"user" yaml:"user"`
Password string `json:"password" yaml:"password"`
Name string `json:"name" yaml:"name"`
Driver string `json:"driver" yaml:"driver"`
}
Elasticsearch struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Index string `json:"index" yaml:"index"`
}
Amqp struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
User string `json:"user" yaml:"user"`
Password string `json:"password" yaml:"password"`
}
Env struct {
Debug bool `json:"debug" yaml:"debug"`
Secret string `json:"secret" yaml:"secret"`
HttpPort int `json:"http_port" yaml:"http_port"`
RpcPort int `json:"rpc_port" yaml:"rpc_port"`
ApiVersion string `json:"api_version" yaml:"api_version"`
Service Service `json:"service" yaml:"service"`
Db Db `json:"database" yaml:"database"`
Elasticsearch Elasticsearch `json:"elasticsearch" yaml:"elasticsearch"`
Amqp Amqp `json:"queue" yaml:"queue"`
RequestIDHeader string `json:"request_id_header" yaml:"request_id_header"`
CacheLifetime int `json:"cache_lifetime" yaml:"cache_lifetime"`
User string
}
)