同步Readme文件

This commit is contained in:
boyce
2019-09-23 15:56:58 +08:00
parent 9623cd2735
commit 79a6b79397
8 changed files with 210 additions and 283 deletions

View File

@@ -1,34 +0,0 @@
package main
import (
"fmt"
"github.com/duanhf2012/origin/cluster"
"github.com/duanhf2012/origin/originnode"
"github.com/duanhf2012/origin/service"
)
type SubNet1_Service struct {
service.BaseService
}
func init() {
originnode.InitService(&SubNet1_Service{})
}
//OnInit ...
func (ws *SubNet1_Service) OnInit() error {
return nil
}
//OnRun ...
func (ws *SubNet1_Service) OnRun() bool {
var in InputData
var ret int
in.A1 = 10
in.A2 = 20
err := cluster.Call("SubNet2_Service1.RPC_Multi", &in, &ret)
fmt.Printf("%+v", err)
return false
}

View File

@@ -1,40 +0,0 @@
package main
import (
"github.com/duanhf2012/origin/originnode"
"github.com/duanhf2012/origin/service"
)
type InputData struct {
A1 int
A2 int
}
type SubNet1_Service1 struct {
service.BaseService
}
func init() {
originnode.InitService(&SubNet1_Service1{})
}
//OnInit ...
func (ws *SubNet1_Service1) OnInit() error {
return nil
}
//OnRun ...
func (ws *SubNet1_Service1) OnRun() bool {
return false
}
//服务要对外的接口规划如下:
//RPC_MethodName(arg *DataType1, ret *DataType2) error
//如果不符合规范,在加载服务时,该函数将不会被映射,其他服务将不允能调用。
func (slf *SubNet1_Service1) RPC_Add(arg *InputData, ret *int) error {
*ret = arg.A1 + arg.A2
return nil
}

View File

@@ -1,31 +0,0 @@
package main
import (
"github.com/duanhf2012/origin/originnode"
"github.com/duanhf2012/origin/service"
)
type SubNet1_Service2 struct {
service.BaseService
}
func init() {
originnode.InitService(&SubNet1_Service2{})
}
//OnInit ...
func (ws *SubNet1_Service2) OnInit() error {
return nil
}
//OnRun ...
func (ws *SubNet1_Service2) OnRun() bool {
return false
}
func (slf *SubNet1_Service2) RPC_Sub(arg *InputData, ret *int) error {
*ret = arg.A1 - arg.A2
return nil
}

View File

@@ -1,31 +0,0 @@
package main
import (
"github.com/duanhf2012/origin/originnode"
"github.com/duanhf2012/origin/service"
)
type SubNet2_Service1 struct {
service.BaseService
}
func init() {
originnode.InitService(&SubNet2_Service1{})
}
//OnInit ...
func (ws *SubNet2_Service1) OnInit() error {
return nil
}
//OnRun ...
func (ws *SubNet2_Service1) OnRun() bool {
return false
}
func (slf *SubNet2_Service1) RPC_Multi(arg *InputData, ret *int) error {
*ret = arg.A1 * arg.A2
return nil
}

View File

@@ -8,38 +8,20 @@
"NodeID": 1,
"NodeName": "N_Node1",
"ServiceList": [
"HttpServerService",
"SubNet1_Service",
"SubNet1_Service1"
"TestService1",
"TestService2"
],
"ClusterNode":["SubNet2.N_Node1","N_Node2"]
"ClusterNode":[]
},
{
"NodeID": 2,
"NodeName": "N_Node2",
"ServiceList": [
"SubNet1_Service2"
"TestService3"
],
"ClusterNode":[]
}
]
},
{
"Remark": "Manual,Full,Auto",
"SubNetMode": "Full",
"SubNetName": "SubNet2",
"PublicServiceList": ["logiclog"],
"NodeList": [{
"NodeID": 3,
"NodeName": "N_Node1",
"ServiceList": [
"SubNet2_Service1"
],
"ClusterNode":["URQ.N_Node1"]
}
]
}
]
}

View File

@@ -1,44 +1,20 @@
{
"Public":{
"LogLevel":1,
"HttpPort":9400,
"WSPort":9500,
"CAFile":[
{
"CertFile":"",
"KeyFile":""
"Public": {
"LogLevel": 1,
"HttpPort": 9400,
"WSPort": 9500,
"Environment": "Test",
"IsListenLog": 1,
"IsSendErrorMail": 0
},
{
"CertFile":"",
"KeyFile":""
}
],
"Environment":"FS_Dev_LFY",
"IsListenLog":1,
"IsSendErrorMail":0
},
"NodeList":[
{
"NodeID":1,
"NodeAddr": "127.0.0.1:8081",
"LogLevel":1,
"HttpPort":7001,
"WSPort":7000,
"CertFile":"",
"KeyFile":""
},
{
"NodeID":2,
"NodeAddr": "127.0.0.1:8082"
}
,
{
"NodeID":3,
"NodeAddr": "127.0.0.1:8083"
}
]
"NodeList": [{
"NodeID": 1,
"NodeAddr": "127.0.0.1:8081"
},
{
"NodeID": 2,
"NodeAddr": "127.0.0.1:8082"
}
]
}

View File

@@ -1,9 +1,7 @@
package main
import (
"github.com/duanhf2012/origin/cluster"
"github.com/duanhf2012/origin/originnode"
"github.com/duanhf2012/origin/sysservice"
)
func main() {
@@ -13,14 +11,6 @@ func main() {
return
}
nodeCfg, _ := cluster.ReadNodeConfig("./config/nodeconfig.json", cluster.GetNodeId())
httpserver := sysservice.NewHttpServerService(nodeCfg.HttpPort) // http服务
for _, ca := range nodeCfg.CAFile {
httpserver.SetHttps(ca.CertFile, ca.KeyFile)
}
httpserver.SetPrintRequestTime(true)
node.SetupService(httpserver)
node.Init()
node.Start()
}