/
config.go
64 lines (52 loc) · 1.69 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
// Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)
package main
import "os"
// IConfig is interface for application config
type IConfig interface {
ServiceID() string
CacheServer() string
MQServers() string
CitizenRegisteredTopic() string
CitizenConfirmedTopic() string
CitizenValidationAPI() string
CitizenDeliveryAPI() string
BatchDeliverAPI() string
}
// Config implement IConfig
type Config struct{}
// NewConfig return new config instance
func NewConfig() *Config {
return &Config{}
}
// ServiceID return ID of service
func (cfg *Config) ServiceID() string {
return os.Getenv("SERVICE_ID")
}
// CacheServer return redis server
func (cfg *Config) CacheServer() string {
return os.Getenv("CACHE_SERVER")
}
// MQServers return Kafka servers
func (cfg *Config) MQServers() string {
return os.Getenv("MQ_SERVERS")
}
// CitizenRegisteredTopic return topic name for registered event
func (cfg *Config) CitizenRegisteredTopic() string {
return "when-citizen-has-registered"
}
// CitizenConfirmedTopic return topic name for confirmed event
func (cfg *Config) CitizenConfirmedTopic() string {
return "when-citizen-has-confirmed"
}
// CitizenValidationAPI return API to validate citizen information
func (cfg *Config) CitizenValidationAPI() string {
return "http://external-api:8080/3rd-party/validate"
}
// CitizenDeliveryAPI return API to request delivery citizen ID card
func (cfg *Config) CitizenDeliveryAPI() string {
return "http://external-api:8080/3rd-party/delivery"
}
// BatchDeliverAPI return API to batch delivery citizen ID card
func (cfg *Config) BatchDeliverAPI() string {
return "http://batch-ptask-api:8080/ptask/delivery"
}