Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
c06463db
Commit
c06463db
authored
Sep 24, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add route method and Fixed appchain process logic bug
parent
a662d619
Pipeline
#8056
canceled with stages
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
11 deletions
+34
-11
port.go
internal/appchain/port.go
+7
-5
const.go
internal/router/const.go
+9
-0
router.go
internal/router/router.go
+10
-4
interface.go
pkg/plugins/interface.go
+2
-2
tool.go
tool/tool.go
+6
-0
No files found.
internal/appchain/port.go
View file @
c06463db
...
@@ -3,6 +3,8 @@ package appchain
...
@@ -3,6 +3,8 @@ package appchain
import
(
import
(
"errors"
"errors"
"github.com/link33/sidecar/internal/repo"
"github.com/link33/sidecar/internal/router"
"github.com/link33/sidecar/model/pb"
"github.com/link33/sidecar/model/pb"
)
)
...
@@ -49,11 +51,11 @@ func (a *appChain) Send(msg *pb.Message) (*pb.Message, error) {
...
@@ -49,11 +51,11 @@ func (a *appChain) Send(msg *pb.Message) (*pb.Message, error) {
//TODO 默认路由
//TODO 默认路由
ix
:=
pb
.
IBTPX
{
ix
:=
pb
.
IBTPX
{
Ibtp
:
ibtp
,
Ibtp
:
ibtp
,
Mode
:
""
,
Mode
:
repo
.
DirectMode
,
RouteSign
:
nil
,
RouteSign
:
[]
string
{}
,
RouteMethod
:
""
,
RouteMethod
:
router
.
Single
,
RouteMethodArg
:
nil
,
RouteMethodArg
:
[]
string
{}
,
IsValid
:
false
,
IsValid
:
false
,
// TODO
}
}
d
,
err
:=
ix
.
Marshal
()
d
,
err
:=
ix
.
Marshal
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
internal/router/const.go
0 → 100644
View file @
c06463db
package
router
var
(
Single
=
"single"
Multicast
=
"multicast"
Broadcast
=
"broadcast"
Official
=
"official"
Random
=
"random"
)
internal/router/router.go
View file @
c06463db
...
@@ -40,10 +40,11 @@ func NewRouter(privateKey crypto.PrivateKey, logger logrus.FieldLogger) Router {
...
@@ -40,10 +40,11 @@ func NewRouter(privateKey crypto.PrivateKey, logger logrus.FieldLogger) Router {
}
}
func
(
r
*
router
)
Start
()
error
{
func
(
r
*
router
)
Start
()
error
{
r
.
methodMap
[
"single"
]
=
r
.
Single
r
.
methodMap
[
Single
]
=
r
.
Single
r
.
methodMap
[
"multicast"
]
=
r
.
Multicast
r
.
methodMap
[
Multicast
]
=
r
.
Multicast
r
.
methodMap
[
"broadcast"
]
=
r
.
Broadcast
r
.
methodMap
[
Broadcast
]
=
r
.
Broadcast
r
.
methodMap
[
"official"
]
=
r
.
Official
r
.
methodMap
[
Official
]
=
r
.
Official
r
.
methodMap
[
Random
]
=
r
.
Random
return
nil
return
nil
}
}
...
@@ -266,6 +267,10 @@ func (r *router) Broadcast([]string) []port.Port {
...
@@ -266,6 +267,10 @@ func (r *router) Broadcast([]string) []port.Port {
return
r
.
portMap
.
AllRouterPort
()
return
r
.
portMap
.
AllRouterPort
()
}
}
func
(
r
*
router
)
Random
([]
string
)
[]
port
.
Port
{
return
[]
port
.
Port
{
r
.
portMap
.
RandRouterPort
()}
}
func
(
r
*
router
)
Official
(
tags
[]
string
)
[]
port
.
Port
{
func
(
r
*
router
)
Official
(
tags
[]
string
)
[]
port
.
Port
{
var
ps
[]
port
.
Port
var
ps
[]
port
.
Port
for
_
,
tag
:=
range
tags
{
for
_
,
tag
:=
range
tags
{
...
@@ -304,4 +309,5 @@ type RouteMethod interface {
...
@@ -304,4 +309,5 @@ type RouteMethod interface {
Multicast
([]
string
)
[]
port
.
Port
Multicast
([]
string
)
[]
port
.
Port
Broadcast
([]
string
)
[]
port
.
Port
Broadcast
([]
string
)
[]
port
.
Port
Official
([]
string
)
[]
port
.
Port
Official
([]
string
)
[]
port
.
Port
Random
([]
string
)
[]
port
.
Port
}
}
pkg/plugins/interface.go
View file @
c06463db
...
@@ -11,9 +11,9 @@ type Kernel interface {
...
@@ -11,9 +11,9 @@ type Kernel interface {
Exited
()
bool
Exited
()
bool
}
}
// Client defines the interface that interacts with appchain
与 appchain交互。
// Client defines the interface that interacts with appchain
//go:generate mockgen -destination mock_client/mock_client.go -package mock_client -source interface.go
//go:generate mockgen -destination mock_client/mock_client.go -package mock_client -source interface.go
type
Client
interface
{
// 业务实现委托接口。
需要实现的那有些。
type
Client
interface
{
// 业务实现委托接口。
internal
.
Launcher
internal
.
Launcher
Kernel
Kernel
Bind
(
kern
Kernel
)
Bind
(
kern
Kernel
)
...
...
tool/tool.go
View file @
c06463db
...
@@ -35,3 +35,9 @@ func Exist(path string) bool {
...
@@ -35,3 +35,9 @@ func Exist(path string) bool {
return
false
return
false
}
}
//https://github.com/fatih/gomodifytags
//https://github.com/favadi/protoc-go-inject-tag
//https://github.com/0xAX/go-algorithms
//https://github.com/emirpasic/gods
//
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment