1- package syncerCommon
1+ package common
22
33import (
44 "errors"
55 "io"
66 "sync"
7-
8- "github.com/BemiHQ/BemiDB/src/common"
97)
108
119type CappedBuffer struct {
12- Config * common. CommonConfig
10+ Config * CommonConfig
1311 MaxSizeBytes int
1412
1513 buffer []byte
@@ -20,7 +18,7 @@ type CappedBuffer struct {
2018 closed bool
2119}
2220
23- func NewCappedBuffer (config * common. CommonConfig , maxSizeBytes int ) * CappedBuffer {
21+ func NewCappedBuffer (config * CommonConfig , maxSizeBytes int ) * CappedBuffer {
2422 sizedBuffer := & CappedBuffer {
2523 Config : config ,
2624 buffer : make ([]byte , 0 , maxSizeBytes ),
@@ -44,7 +42,7 @@ func (buf *CappedBuffer) Write(payload []byte) (writtenBytes int, err error) {
4442 }
4543
4644 for len (buf .buffer )+ len (payload ) > buf .MaxSizeBytes && ! buf .closed {
47- common . LogTrace (buf .Config , ">> Waiting for more space in capped buffer..." )
45+ LogTrace (buf .Config , ">> Waiting for more space in capped buffer..." )
4846 buf .conditionalSync .Wait () // Wait for the reader
4947 }
5048
@@ -55,7 +53,7 @@ func (buf *CappedBuffer) Write(payload []byte) (writtenBytes int, err error) {
5553
5654 writtenBytes = len (payload )
5755 buf .buffer = append (buf .buffer , payload ... )
58- common . LogTrace (buf .Config , ">> Writing" , writtenBytes , "bytes to capped buffer..." )
56+ LogTrace (buf .Config , ">> Writing" , writtenBytes , "bytes to capped buffer..." )
5957
6058 buf .conditionalSync .Broadcast () // Notify the reader that new data is available
6159
@@ -72,7 +70,7 @@ func (buf *CappedBuffer) Read(payload []byte) (readBytes int, err error) {
7270 defer buf .mutex .Unlock ()
7371
7472 for len (buf .buffer ) == 0 && ! buf .closed {
75- common . LogTrace (buf .Config , "<< Waiting for more data in capped buffer..." )
73+ LogTrace (buf .Config , "<< Waiting for more data in capped buffer..." )
7674 buf .conditionalSync .Wait () // Wait for the writer
7775 }
7876
@@ -83,7 +81,7 @@ func (buf *CappedBuffer) Read(payload []byte) (readBytes int, err error) {
8381 maxReadBytes := len (payload )
8482 readBytes = copy (payload , buf .buffer )
8583 buf .buffer = buf .buffer [readBytes :]
86- common . LogTrace (buf .Config , "<< Reading " + common . IntToString (readBytes )+ "/" + common . IntToString (maxReadBytes )+ " bytes from capped buffer..." )
84+ LogTrace (buf .Config , "<< Reading " + IntToString (readBytes )+ "/" + IntToString (maxReadBytes )+ " bytes from capped buffer..." )
8785
8886 buf .conditionalSync .Broadcast () // Notify the writer that space is now available
8987
@@ -94,7 +92,7 @@ func (buf *CappedBuffer) Close() error {
9492 buf .closeOnceSync .Do (func () {
9593 buf .mutex .Lock ()
9694
97- common . LogTrace (buf .Config , "== Closing capped buffer..." )
95+ LogTrace (buf .Config , "== Closing capped buffer..." )
9896 buf .closed = true
9997
10098 buf .conditionalSync .Broadcast () // Wake up any waiting writers/readers
0 commit comments