Skip to content

Commit e75042f

Browse files
committed
initial commit
1 parent c8704cc commit e75042f

File tree

28 files changed

+1783
-13
lines changed

28 files changed

+1783
-13
lines changed

.gitignore

+50-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,52 @@
1-
# Binaries for programs and plugins
2-
*.exe
3-
*.exe~
4-
*.dll
5-
*.so
6-
*.dylib
7-
8-
# Test binary, built with `go test -c`
9-
*.test
101

11-
# Output of the go coverage tool, specifically when used with LiteIDE
12-
*.out
2+
.DS_Store
3+
*.[56789ao]
4+
*.a[56789o]
5+
*.so
6+
*.pyc
7+
._*
8+
.nfs.*
9+
[56789a].out
10+
*~
11+
*.orig
12+
*.rej
13+
*.exe
14+
.*.swp
15+
core
16+
*.cgo*.go
17+
*.cgo*.c
18+
_cgo_*
19+
_obj
20+
_test
21+
_testmain.go
22+
/VERSION.cache
23+
/bin/
24+
/build.out
25+
/doc/articles/wiki/*.bin
26+
/goinstall.log
27+
/last-change
28+
/misc/cgo/life/run.out
29+
/misc/cgo/stdio/run.out
30+
/misc/cgo/testso/main
31+
/pkg/
32+
/src/*.*/
33+
/src/cmd/cgo/zdefaultcc.go
34+
/src/cmd/dist/dist
35+
/src/cmd/go/internal/cfg/zdefaultcc.go
36+
/src/cmd/go/internal/cfg/zosarch.go
37+
/src/cmd/internal/objabi/zbootstrap.go
38+
/src/go/build/zcgo.go
39+
/src/go/doc/headscan
40+
/src/runtime/internal/sys/zversion.go
41+
/src/unicode/maketables
42+
/test.out
43+
/test/garbage/*.out
44+
/test/pass.out
45+
/test/run.out
46+
/test/times.out
47+
# This file includes artifacts of Go build that should not be checked in.
48+
# For files created by specific development environment (e.g. editor),
49+
# use alternative ways to exclude files from git.
50+
# For example, set up .git/info/exclude or use a global .gitignore.
1351

14-
# Dependency directories (remove the comment below to include it)
15-
# vendor/
52+
.idea

cmd/api/read/main.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"github.com/cemayan/url-shortener/config/api"
5+
"github.com/cemayan/url-shortener/handlers/db"
6+
"github.com/cemayan/url-shortener/internal/api/read/adapter/database"
7+
"github.com/sirupsen/logrus"
8+
"github.com/spf13/viper"
9+
"os"
10+
)
11+
12+
var _log *logrus.Logger
13+
var configs *api.AppConfig
14+
var v *viper.Viper
15+
16+
func init() {
17+
_log = logrus.New()
18+
if os.Getenv("env") == "dev" {
19+
_log.SetFormatter(&logrus.TextFormatter{
20+
DisableColors: false,
21+
FullTimestamp: true,
22+
})
23+
} else {
24+
_log.SetFormatter(&logrus.JSONFormatter{})
25+
_log.SetOutput(os.Stdout)
26+
}
27+
_log.Out = os.Stdout
28+
29+
v = viper.New()
30+
_configs := api.NewConfig(v)
31+
32+
env := os.Getenv("env")
33+
appConfig, err := _configs.GetConfig(env)
34+
configs = appConfig
35+
if err != nil {
36+
return
37+
}
38+
39+
dbHandler := db.NewCockroachDbHandler(&configs.Cockroach, _log.WithFields(logrus.Fields{"service": "database"}))
40+
_db := dbHandler.New()
41+
database.DB = _db
42+
//util.MigrateDB(_db, _log.WithFields(logrus.Fields{"service": "database"}))
43+
}
44+
45+
func main() {
46+
47+
}

cmd/api/write/main.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"github.com/cemayan/url-shortener/config/api"
5+
"github.com/cemayan/url-shortener/handlers/db"
6+
"github.com/cemayan/url-shortener/internal/api/read/adapter/database"
7+
"github.com/sirupsen/logrus"
8+
"github.com/spf13/viper"
9+
"os"
10+
)
11+
12+
var _log *logrus.Logger
13+
var configs *api.AppConfig
14+
var v *viper.Viper
15+
16+
func init() {
17+
_log = logrus.New()
18+
if os.Getenv("env") == "dev" {
19+
_log.SetFormatter(&logrus.TextFormatter{
20+
DisableColors: false,
21+
FullTimestamp: true,
22+
})
23+
} else {
24+
_log.SetFormatter(&logrus.JSONFormatter{})
25+
_log.SetOutput(os.Stdout)
26+
}
27+
_log.Out = os.Stdout
28+
29+
v = viper.New()
30+
_configs := api.NewConfig(v)
31+
32+
env := os.Getenv("env")
33+
appConfig, err := _configs.GetConfig(env)
34+
configs = appConfig
35+
if err != nil {
36+
return
37+
}
38+
39+
dbHandler := db.NewCockroachDbHandler(&configs.Cockroach, _log.WithFields(logrus.Fields{"service": "database"}))
40+
_db := dbHandler.New()
41+
database.DB = _db
42+
//util.MigrateDB(_db, _log.WithFields(logrus.Fields{"service": "database"}))
43+
}
44+
45+
func main() {
46+
47+
}

cmd/auth/main.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"github.com/cemayan/url-shortener/config/user"
5+
"github.com/sirupsen/logrus"
6+
"github.com/spf13/viper"
7+
"os"
8+
)
9+
10+
var _log *logrus.Logger
11+
var configs *user.AppConfig
12+
var v *viper.Viper
13+
14+
func init() {
15+
_log = logrus.New()
16+
if os.Getenv("env") == "dev" {
17+
_log.SetFormatter(&logrus.TextFormatter{
18+
DisableColors: false,
19+
FullTimestamp: true,
20+
})
21+
} else {
22+
_log.SetFormatter(&logrus.JSONFormatter{})
23+
_log.SetOutput(os.Stdout)
24+
}
25+
_log.Out = os.Stdout
26+
27+
v = viper.New()
28+
_configs := user.NewConfig(v)
29+
30+
env := os.Getenv("env")
31+
appConfig, err := _configs.GetConfig(env)
32+
configs = appConfig
33+
if err != nil {
34+
return
35+
}
36+
37+
}
38+
39+
func main() {
40+
41+
}

cmd/event_handler/main.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"github.com/cemayan/url-shortener/config/event_handler"
5+
"github.com/cemayan/url-shortener/handlers/db"
6+
"github.com/cemayan/url-shortener/internal/event_handler/adapter/database"
7+
"github.com/sirupsen/logrus"
8+
"github.com/spf13/viper"
9+
"os"
10+
)
11+
12+
var _log *logrus.Logger
13+
var configs *event_handler.AppConfig
14+
var v *viper.Viper
15+
16+
func init() {
17+
_log = logrus.New()
18+
if os.Getenv("env") == "dev" {
19+
_log.SetFormatter(&logrus.TextFormatter{
20+
DisableColors: false,
21+
FullTimestamp: true,
22+
})
23+
} else {
24+
_log.SetFormatter(&logrus.JSONFormatter{})
25+
_log.SetOutput(os.Stdout)
26+
}
27+
_log.Out = os.Stdout
28+
29+
v = viper.New()
30+
_configs := event_handler.NewConfig(v)
31+
32+
env := os.Getenv("env")
33+
appConfig, err := _configs.GetConfig(env)
34+
configs = appConfig
35+
if err != nil {
36+
return
37+
}
38+
39+
dbHandler := db.NewCockroachDbHandler(&configs.Cockroach, _log.WithFields(logrus.Fields{"service": "database"}))
40+
_db := dbHandler.New()
41+
database.DB = _db
42+
//util.MigrateDB(_db, _log.WithFields(logrus.Fields{"service": "database"}))
43+
}
44+
45+
func main() {
46+
47+
}

cmd/user/main.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"github.com/cemayan/url-shortener/config/user"
5+
"github.com/sirupsen/logrus"
6+
"github.com/spf13/viper"
7+
"os"
8+
)
9+
10+
var _log *logrus.Logger
11+
var configs *user.AppConfig
12+
var v *viper.Viper
13+
14+
func init() {
15+
_log = logrus.New()
16+
if os.Getenv("env") == "dev" {
17+
_log.SetFormatter(&logrus.TextFormatter{
18+
DisableColors: false,
19+
FullTimestamp: true,
20+
})
21+
} else {
22+
_log.SetFormatter(&logrus.JSONFormatter{})
23+
_log.SetOutput(os.Stdout)
24+
}
25+
_log.Out = os.Stdout
26+
27+
v = viper.New()
28+
_configs := user.NewConfig(v)
29+
30+
env := os.Getenv("env")
31+
appConfig, err := _configs.GetConfig(env)
32+
configs = appConfig
33+
if err != nil {
34+
return
35+
}
36+
}
37+
38+
func main() {
39+
40+
}

common/common.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package common
2+
3+
type Cockroach struct {
4+
Host string
5+
Port string
6+
User string
7+
Password string
8+
Name string
9+
}
10+
11+
type Mongo struct {
12+
Url string
13+
DbName string
14+
}
15+
16+
type Kafka struct {
17+
Url string
18+
Topic string
19+
}
20+
21+
type Pulsar struct {
22+
Url string
23+
Topic string
24+
}

config/api/config-dev.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cockroach:
2+
Host: localhost
3+
Name: us_metadata
4+
Port: 26257
5+
User: root
6+
mongo:
7+
DbName: eseventstore
8+
url: mongodb://localhost:27017
9+
secret: secret
10+

0 commit comments

Comments
 (0)