From ce66428ae4300146f7a853b53816065750fa7c6f Mon Sep 17 00:00:00 2001 From: Andrew LeFevre Date: Thu, 21 Nov 2019 13:30:36 -0500 Subject: [PATCH] make 'Out' channel of nodes buffered --- nodes/db/dbnode.go | 4 +++- nodes/fs/fsnode.go | 4 +++- nodes/qldb/qlnode.go | 4 +++- nodes/ram/ramnode.go | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/nodes/db/dbnode.go b/nodes/db/dbnode.go index fd57878..48b2e53 100644 --- a/nodes/db/dbnode.go +++ b/nodes/db/dbnode.go @@ -14,6 +14,8 @@ import ( "upper.io/db.v3/lib/sqlbuilder" ) +var OutBufferSize = 128 + // Node : defines an instance of the API with a ql-DB backed Node type Node struct { contentKey bc.KeyPair @@ -52,7 +54,7 @@ func New(contentKey, routingKey bc.KeyPair) *Node { // setup chans node.in = make(chan api.Msg) - node.out = make(chan api.Msg) + node.out = make(chan api.Msg, OutBufferSize) node.events = make(chan api.Event) // setup default router diff --git a/nodes/fs/fsnode.go b/nodes/fs/fsnode.go index 00ad673..b3e89e6 100644 --- a/nodes/fs/fsnode.go +++ b/nodes/fs/fsnode.go @@ -13,6 +13,8 @@ import ( "github.com/awgh/ratnet/router" ) +var OutBufferSize = 128 + type outboxMsg struct { channel string msg []byte @@ -68,7 +70,7 @@ func New(contentKey, routingKey bc.KeyPair, basePath string) *Node { // setup chans node.in = make(chan api.Msg) - node.out = make(chan api.Msg) + node.out = make(chan api.Msg, OutBufferSize) node.events = make(chan api.Event) // setup default router diff --git a/nodes/qldb/qlnode.go b/nodes/qldb/qlnode.go index b66ed08..0780e17 100644 --- a/nodes/qldb/qlnode.go +++ b/nodes/qldb/qlnode.go @@ -16,6 +16,8 @@ import ( _ "modernc.org/ql/driver" // load the QL database driver ) +var OutBufferSize = 128 + // Node : defines an instance of the API with a ql-DB backed Node type Node struct { contentKey bc.KeyPair @@ -52,7 +54,7 @@ func New(contentKey, routingKey bc.KeyPair) *Node { // setup chans node.in = make(chan api.Msg) - node.out = make(chan api.Msg) + node.out = make(chan api.Msg, OutBufferSize) node.events = make(chan api.Event) // setup default router diff --git a/nodes/ram/ramnode.go b/nodes/ram/ramnode.go index e38e109..60e810d 100644 --- a/nodes/ram/ramnode.go +++ b/nodes/ram/ramnode.go @@ -9,6 +9,8 @@ import ( "github.com/awgh/ratnet/router" ) +var OutBufferSize = 128 + // Node : defines an instance of the API with a ql-DB backed Node type Node struct { contentKey bc.KeyPair @@ -69,7 +71,7 @@ func New(contentKey, routingKey bc.KeyPair) *Node { // setup chans node.in = make(chan api.Msg) - node.out = make(chan api.Msg) + node.out = make(chan api.Msg, OutBufferSize) node.events = make(chan api.Event) // setup default router