Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ init:
@sh ./devops/grpc_gen.sh

update:
@git submodule foreach git pull --allow-unrelated-histories
@git submodule foreach git pull --rebase --allow-unrelated-histories

# generate_c:
# protoc --proto_path=devops/idl --go_out=plugins=grpc:grpc_gen devops/idl/user/info.proto \
# protoc --proto_path=devops/idl --go_out=plugins=grpc:grpc_gen devops/idl/comment/info.proto \
# protoc --proto_path=devops/idl --go_out=plugins=grpc:grpc_gen devops/idl/content/info.proto
2 changes: 1 addition & 1 deletion devops/idl
Submodule idl updated from e3bf01 to f58f0f
41 changes: 41 additions & 0 deletions di/container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package di

import (
"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
"github.com/sundogrd/content-api/grpc_gen/comment"
"github.com/sundogrd/content-api/grpc_gen/content"
"github.com/sundogrd/content-api/grpc_gen/user"
commentGrpc "github.com/sundogrd/content-api/providers/grpc/comment"
contentGrpc "github.com/sundogrd/content-api/providers/grpc/content"
"github.com/sundogrd/content-api/utils/redis"
)

type Container struct {
GormDB *gorm.DB
RedisClient *redis.Client
CommentGrpcClient comment.CommentServiceClient
ContentGrpcClient content.ContentServiceClient
UserGrpcClient user.UserServiceClient
}

func InitContainer() (*Container, error) {
commentClient, _, err := commentGrpc.NewGrpcCommentClient()
if err != nil {
logrus.Errorf("[Main] Init commentClient error: %+v", err)
return nil, err
}
logrus.Infof("comment grpc client init success")

contentClient, _, err := contentGrpc.NewGrpcContentClient()
if err != nil {
logrus.Errorf("[Main] Init commentClient error: %+v", err)
return nil, err
}
logrus.Infof("content grpc client init success")

return &Container{
CommentGrpcClient: commentClient,
ContentGrpcClient: contentClient,
}, nil
}
15 changes: 0 additions & 15 deletions env/container.go

This file was deleted.

4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Jeffail/gabs v1.2.0 h1:uFhoIVTtsX7hV2RxNgWad8gMU+8OJdzFbOathJdhD3o=
github.com/Jeffail/gabs v1.2.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
Expand Down Expand Up @@ -265,6 +268,7 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down
Loading