Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
bc3f1809
Unverified
Commit
bc3f1809
authored
May 30, 2018
by
Daniel Czerwonk
Committed by
GitHub
May 30, 2018
Browse files
Options
Downloads
Plain Diff
Merge pull request #36 from hikhvar/feature/sleep-between-reconnects
Feature: Only activate the fsm at configurable reconnectInterval
parents
6978b867
c9f5158a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/peer.go
+14
-11
14 additions, 11 deletions
config/peer.go
protocols/bgp/server/peer.go
+31
-15
31 additions, 15 deletions
protocols/bgp/server/peer.go
with
45 additions
and
26 deletions
config/peer.go
+
14
−
11
View file @
bc3f1809
...
...
@@ -3,6 +3,8 @@ package config
import
(
"net"
"time"
"github.com/bio-routing/bio-rd/routingtable"
)
...
...
@@ -18,4 +20,5 @@ type Peer struct {
RouterID
uint32
AddPathSend
routingtable
.
ClientOptions
AddPathRecv
bool
ReconnectInterval
time
.
Duration
}
This diff is collapsed.
Click to expand it.
protocols/bgp/server/peer.go
+
31
−
15
View file @
bc3f1809
...
...
@@ -6,6 +6,8 @@ import (
"github.com/bio-routing/bio-rd/config"
"github.com/bio-routing/bio-rd/protocols/bgp/packet"
"github.com/bio-routing/bio-rd/routingtable"
"time"
)
type
Peer
struct
{
...
...
@@ -17,8 +19,11 @@ type Peer struct {
addPathSend
routingtable
.
ClientOptions
addPathRecv
bool
optOpenParams
[]
packet
.
OptParam
reconnectInterval
time
.
Duration
}
// NewPeer creates a new peer with the given config. If an connection is established, the adjRIBIN of the peer is connected
// to the given rib. To actually connect the peer, call Start() on the returned peer.
func
NewPeer
(
c
config
.
Peer
,
rib
routingtable
.
RouteTableClient
)
(
*
Peer
,
error
)
{
p
:=
&
Peer
{
addr
:
c
.
PeerAddress
,
...
...
@@ -27,6 +32,7 @@ func NewPeer(c config.Peer, rib routingtable.RouteTableClient) (*Peer, error) {
addPathSend
:
c
.
AddPathSend
,
addPathRecv
:
c
.
AddPathRecv
,
optOpenParams
:
make
([]
packet
.
OptParam
,
0
),
reconnectInterval
:
c
.
ReconnectInterval
,
}
p
.
fsm
=
NewFSM
(
p
,
c
,
rib
)
...
...
@@ -61,18 +67,28 @@ func NewPeer(c config.Peer, rib routingtable.RouteTableClient) (*Peer, error) {
return
p
,
nil
}
// GetAddr returns the IP address of the peer
func
(
p
*
Peer
)
GetAddr
()
net
.
IP
{
return
p
.
addr
}
// GetASN returns the configured AS number of the peer
func
(
p
*
Peer
)
GetASN
()
uint32
{
return
p
.
asn
}
// Start the peers fsm. It starts from the Idle state and will get an ManualStart event. To trigger
// reconnects if the fsm falls back into the Idle state, every reconnectInterval a ManualStart event is send.
// The default value for reconnectInterval is 30 seconds.
func
(
p
*
Peer
)
Start
()
{
p
.
fsm
.
start
()
if
p
.
reconnectInterval
==
0
{
p
.
reconnectInterval
=
30
*
time
.
Second
}
t
:=
time
.
Tick
(
p
.
reconnectInterval
)
go
func
()
{
for
{
<-
t
p
.
fsm
.
activate
()
}
}()
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment