上传初始化项目代码

This commit is contained in:
liwei1dao 2022-05-27 17:27:01 +08:00
parent 54376300de
commit bb583c2663
16 changed files with 1360 additions and 0 deletions

21
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,21 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gate",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/services/gate", //Gomain.go,${workspaceRoot}, /bin /pkg /src
"args": ["-conf","./conf/gate.yaml"],
"cwd": "${workspaceFolder}/bin", //
"internalConsoleOptions": "openOnSessionStart",
"output": "${workspaceFolder}/bin/vsdebug_gate", //vscode
"showGlobalVariables": true,
"env": {}, //,gopathgopath:gopath
}
]
}

11
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"window.zoomLevel": 1,
"go.docsTool": "gogetdoc",
"go.formatTool": "goimports",
"explorer.confirmDelete": false,
"go.lintFlags": ["--disable=varcheck", "--enable=errcheck"],
"files.exclude": {
"*-template/": true
}
}

0
bin/conf/gate.yaml Normal file
View File

1
cmd/cmd.go Normal file
View File

@ -0,0 +1 @@
package cmd

8
comm/core.go Normal file
View File

@ -0,0 +1,8 @@
package comm
import "github.com/liwei1dao/lego/core"
const (
SM_GateModule core.M_Modules = "SM_GateModule" //gate模块 网关服务模块
)

70
go.mod Normal file
View File

@ -0,0 +1,70 @@
module go_dreamfactory
go 1.18
require github.com/liwei1dao/lego v0.0.0-20220526095312-21dd84c750c5
require (
github.com/Shopify/sarama v1.30.1 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.885 // indirect
github.com/armon/go-metrics v0.3.6 // indirect
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/consul/api v1.8.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.12.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.9.5 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect
github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nacos-group/nacos-sdk-go v1.0.8 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/nats-io/jwt v1.1.0 // indirect
github.com/nats-io/nats.go v1.10.0 // indirect
github.com/nats-io/nkeys v0.1.4 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rs/xid v1.3.0 // indirect
github.com/shirou/gopsutil v3.20.12+incompatible // indirect
github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

1095
go.sum Normal file

File diff suppressed because it is too large Load Diff

35
modules/gate/module.go Normal file
View File

@ -0,0 +1,35 @@
package gate
import (
"go_dreamfactory/comm"
"github.com/liwei1dao/lego/base"
"github.com/liwei1dao/lego/core"
"github.com/liwei1dao/lego/core/cbase"
)
func NewModule() core.IModule {
m := new(Gate)
return m
}
type Gate struct {
cbase.ModuleBase
options *Options
service base.IClusterService
}
func (this *Gate) GetType() core.M_Modules {
return comm.SM_GateModule
}
func (this *Gate) NewOptions() (options core.IModuleOptions) {
return new(Options)
}
func (this *Gate) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IClusterService)
this.options = options.(*Options)
return
}

18
modules/gate/options.go Normal file
View File

@ -0,0 +1,18 @@
package gate
import (
"github.com/liwei1dao/lego/utils/mapstructure"
)
type (
Options struct {
WSAddr string
}
)
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil {
err = mapstructure.Decode(settings, this)
}
return
}

1
modules/web/module.go Normal file
View File

@ -0,0 +1 @@
package web

2
pb/proto/comm.proto Normal file
View File

@ -0,0 +1,2 @@
syntax = "proto3";
option go_package = ".;pb";

43
services/gate/main.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"flag"
"go_dreamfactory/modules/gate"
"go_dreamfactory/services"
"github.com/liwei1dao/lego"
"github.com/liwei1dao/lego/base/cluster"
"github.com/liwei1dao/lego/core"
)
var (
conf = flag.String("conf", "./conf/gate.yaml", "获取需要启动的服务配置文件") //启动服务的Id
)
func main() {
flag.Parse()
s := NewService(
cluster.SetConfPath(*conf),
cluster.SetVersion("1.0.0.0"),
)
s.OnInstallComp( //装备组件
)
lego.Run(s, //运行模块
gate.NewModule(),
)
}
func NewService(ops ...cluster.Option) core.IService {
s := new(Service)
s.Configure(ops...)
return s
}
type Service struct {
services.ServiceBase
}
func (this *Service) InitSys() {
this.ServiceBase.InitSys()
}

13
services/servicebase.go Normal file
View File

@ -0,0 +1,13 @@
package services
import (
"github.com/liwei1dao/lego/base/cluster"
)
type ServiceBase struct {
cluster.ClusterService
}
func (this *ServiceBase) InitSys() {
this.ClusterService.InitSys()
}

40
services/worker/main.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"flag"
"go_dreamfactory/services"
"github.com/liwei1dao/lego"
"github.com/liwei1dao/lego/base/cluster"
"github.com/liwei1dao/lego/core"
)
var (
conf = flag.String("conf", "./conf/worker.yaml", "获取需要启动的服务配置文件") //启动服务的Id
)
func main() {
flag.Parse()
s := NewService(
cluster.SetConfPath(*conf),
cluster.SetVersion("1.0.0.0"),
)
s.OnInstallComp( //装备组件
)
lego.Run(s) //运行模块
}
func NewService(ops ...cluster.Option) core.IService {
s := new(Service)
s.Configure(ops...)
return s
}
type Service struct {
services.ServiceBase
}
func (this *Service) InitSys() {
this.ServiceBase.InitSys()
}

1
sys/redis/core.go Normal file
View File

@ -0,0 +1 @@
package redis

1
utils/utils.go Normal file
View File

@ -0,0 +1 @@
package utils