Add http server
diff --git a/core/kg/model/config.go b/core/kg/model/config.go
index 021fb74..04cc39b 100644
--- a/core/kg/model/config.go
+++ b/core/kg/model/config.go
@@ -3,10 +3,20 @@
const (
databaseDriverPostgres = "postgres"
defaultDataSource = "postgres://user:test@localhost/pcloud_test?sslmode=disable&connect_timeout=10"
+
+ defaultHTTPHost = "0.0.0.0"
+ defaultHTTPPort = 9086
+ defaultHTTPReadTimeout = 5
+ defaultHTTPWriteTimeout = 10
+ defaultHTTPIdleTimeout = 120
+
+ defaultGRPCPort = 9087
)
type Config struct {
- SqlSettings SqlSettings
+ SQLSettings SQLSettings
+ HTTPSettings HTTPSettings
+ GRPCSettings GRPCSettings
}
func NewConfig() *Config {
@@ -16,15 +26,17 @@
}
func (c *Config) SetDefaults() {
- c.SqlSettings.SetDefaults()
+ c.SQLSettings.SetDefaults()
+ c.HTTPSettings.SetDefaults()
+ c.GRPCSettings.SetDefaults()
}
-type SqlSettings struct {
- DriverName string `access:"environment,write_restrictable,cloud_restrictable"`
- DataSource string `access:"environment,write_restrictable,cloud_restrictable"`
+type SQLSettings struct {
+ DriverName string
+ DataSource string
}
-func (s *SqlSettings) SetDefaults() {
+func (s *SQLSettings) SetDefaults() {
if s.DriverName == "" {
s.DriverName = databaseDriverPostgres
}
@@ -33,3 +45,43 @@
s.DataSource = defaultDataSource
}
}
+
+type HTTPSettings struct {
+ Host string
+ Port int
+ ReadTimeout int
+ WriteTimeout int
+ IdleTimeout int
+}
+
+func (s *HTTPSettings) SetDefaults() {
+ if s.Host == "" {
+ s.Host = defaultHTTPHost
+ }
+
+ if s.Port == 0 {
+ s.Port = defaultHTTPPort
+ }
+
+ if s.ReadTimeout == 0 {
+ s.ReadTimeout = defaultHTTPReadTimeout
+ }
+
+ if s.WriteTimeout == 0 {
+ s.WriteTimeout = defaultHTTPWriteTimeout
+ }
+
+ if s.IdleTimeout == 0 {
+ s.IdleTimeout = defaultHTTPIdleTimeout
+ }
+}
+
+type GRPCSettings struct {
+ Port int
+}
+
+func (s *GRPCSettings) SetDefaults() {
+ if s.Port == 0 {
+ s.Port = defaultGRPCPort
+ }
+}