forked from ebhomengo/niki
added cmd and deploy layer
This commit is contained in:
parent
50d7c2a2dc
commit
2037e58a1d
|
|
@ -0,0 +1 @@
|
||||||
|
package command
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
package command
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
package command
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/logger"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/pkg/httpserver"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/shoppingbasketapp"
|
||||||
|
"git.gocasts.ir/ebhomengo/niki/shoppingbasketapp/repository"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cfg := shoppingbasketapp.Config{
|
||||||
|
Redis: redis.Config{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 6379,
|
||||||
|
Password: "",
|
||||||
|
DB: 0,
|
||||||
|
},
|
||||||
|
Repo: repository.Config{
|
||||||
|
KartKeyPrefix: "shopping-basket-cart:",
|
||||||
|
TTL: 3600 * time.Second,
|
||||||
|
},
|
||||||
|
HTTPServer: httpserver.Config{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 8080,
|
||||||
|
ShutdownTimeout: 10 * time.Second,
|
||||||
|
},
|
||||||
|
Logger: logger.Config{
|
||||||
|
FilePath: "logs/shoppingbasket/service.log",
|
||||||
|
UseLocalTime: true,
|
||||||
|
FileMaxSizeInMB: 10,
|
||||||
|
FileMaxAgeInDays: 30,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
app, err := shoppingbasketapp.Setup(cfg)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("error initialize to setup app: %s", err.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
|
app.Start()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
redis:
|
||||||
|
host: "localhost"
|
||||||
|
port: 6379
|
||||||
|
password: ""
|
||||||
|
db: 0
|
||||||
|
|
||||||
|
repo:
|
||||||
|
kart_key_prefix: "shopping-basket-cart:"
|
||||||
|
ttl: 3600s
|
||||||
|
|
||||||
|
http_server:
|
||||||
|
host: "localhost"
|
||||||
|
port: 8080
|
||||||
|
shutdown_context_timeout: 10s
|
||||||
|
|
||||||
|
logger:
|
||||||
|
file_path: "logs/shoppingbasket/service.log"
|
||||||
|
use_local_time: true
|
||||||
|
file_max_size_in_mb: 10
|
||||||
|
file_max_age_in_days: 30
|
||||||
|
|
@ -16,10 +16,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
FilePath string
|
FilePath string `koanf:"file_path"`
|
||||||
UseLocalTime bool
|
UseLocalTime bool `koanf:"use_local_time"`
|
||||||
FileMaxSizeInMB int
|
FileMaxSizeInMB int `koanf:"file_max_size_in_mb"`
|
||||||
FileMaxAgeInDays int
|
FileMaxAgeInDays int `koanf:"file_max_age_in_days"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var l *slog.Logger
|
var l *slog.Logger
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ type Application struct {
|
||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app Application) Setup(cfg Config) (Application, error) {
|
func Setup(cfg Config) (Application, error) {
|
||||||
l := logger.New(cfg.Logger, &slog.HandlerOptions{
|
l := logger.New(cfg.Logger, &slog.HandlerOptions{
|
||||||
Level: slog.LevelDebug,
|
Level: slog.LevelDebug,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue