-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from hardcore-os/logic_dev
feat: 用户领域服务框架开发
- Loading branch information
Showing
31 changed files
with
2,372 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/hardcore-os/plato/domain/user" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
userCmd.AddCommand(domainCMD) | ||
rootCmd.AddCommand(userCmd) | ||
} | ||
|
||
var userCmd = &cobra.Command{ | ||
Use: "user", | ||
Short: "这是用户模块的命令,通常有api和domain两个子命令", | ||
} | ||
|
||
var domainCMD = &cobra.Command{ | ||
Use: "domain", | ||
Run: DomainHandle, | ||
} | ||
|
||
func DomainHandle(cmd *cobra.Command, args []string) { | ||
user.RunMain(ConfigPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package event | ||
|
||
type Channel string | ||
|
||
const ( | ||
UserEvent Channel = "user_event" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package event | ||
|
||
type Manager struct { | ||
channelsConf map[Channel]*Options | ||
channels map[Channel]mq | ||
} | ||
|
||
type mq interface { | ||
Send(event interface{}) | ||
Receive() <-chan interface{} | ||
} | ||
|
||
func NewManager(opts map[Channel]*Options) *Manager { | ||
return &Manager{channelsConf: opts} | ||
} | ||
|
||
func (m *Manager) Send(c Channel, data interface{}) { | ||
|
||
} | ||
|
||
func (m *Manager) Receive(c Channel) interface{} { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package event | ||
|
||
type Options struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cache | ||
|
||
type localCache struct{} | ||
|
||
func newLocalCache(opt *Options) *localCache { | ||
return &localCache{} | ||
} | ||
|
||
func (r *localCache) MSet(keys map[string]interface{}) { | ||
|
||
} | ||
|
||
func (r *localCache) MGet(key []string) map[string]interface{} { | ||
return nil | ||
} | ||
|
||
func (r *localCache) MDel(key []string) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package cache | ||
|
||
type mode = string | ||
|
||
const ( | ||
Local mode = "local" | ||
Remote mode = "remote" | ||
) | ||
|
||
type Options struct { | ||
Mode mode | ||
} | ||
|
||
type cache interface { | ||
MSet(keys map[string]interface{}) | ||
MGet(key []string) map[string]interface{} | ||
MDel(key []string) | ||
} | ||
|
||
type Manager struct { | ||
opts []*Options | ||
cacheList []cache | ||
} | ||
|
||
func NewManager(opts []*Options) *Manager { | ||
m := &Manager{opts: opts, cacheList: make([]cache, 0)} | ||
for _, opt := range opts { | ||
switch opt.Mode { | ||
case Local: | ||
m.cacheList = append(m.cacheList, newLocalCache(opt)) | ||
case Remote: | ||
m.cacheList = append(m.cacheList, newRedisCache(opt)) | ||
} | ||
} | ||
return m | ||
} | ||
|
||
func (m *Manager) MSet(keys map[string]interface{}) { | ||
|
||
} | ||
|
||
func (m *Manager) MGet(key []string) map[string]interface{} { | ||
return nil | ||
} | ||
|
||
func (m *Manager) MDel(key []string) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package config | ||
|
||
import "github.com/spf13/viper" | ||
|
||
func GetDomainUserServerName() string { | ||
return viper.GetString("user_domain.service_name") | ||
} | ||
|
||
func GetDomainUserServerAddr() string { | ||
return viper.GetString("user_domain.service_addr") | ||
} | ||
|
||
func GetDomainUserServerPoint() int { | ||
return viper.GetInt("user_dimain.service_port") | ||
} | ||
func GetDomainUserRPCWeight() int { | ||
return viper.GetInt("user_dimain.weight") | ||
} | ||
func GetDomainUserDBDNS() string { | ||
return viper.GetString("user_dimain.db_dns") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
idl目录存储全项目通用的可复用的标准化结构体定义 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
|
||
option go_package = "common/idl/base"; | ||
//protoc --go-grpc_out=. --go_out=. ./common/idl/base/base.proto | ||
package base; | ||
|
||
|
||
message BaseResp { | ||
uint32 Code = 1; | ||
string Msg = 2; | ||
string LogID = 3; | ||
} |
Oops, something went wrong.