Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
239567f0
Commit
239567f0
authored
Aug 29, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
379cc163
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
26 deletions
+30
-26
go/neo/client/client.go
go/neo/client/client.go
+0
-26
go/neo/client/util.go
go/neo/client/util.go
+26
-0
go/neo/connection.go
go/neo/connection.go
+4
-0
No files found.
go/neo/client/client.go
View file @
239567f0
...
@@ -21,12 +21,9 @@
...
@@ -21,12 +21,9 @@
package
client
package
client
import
(
import
(
"bytes"
"compress/zlib"
"context"
"context"
"crypto/sha1"
"crypto/sha1"
"fmt"
"fmt"
"io"
"math/rand"
"math/rand"
"net/url"
"net/url"
...
@@ -104,29 +101,6 @@ func (c *Client) LastOid(ctx context.Context) (zodb.Oid, error) {
...
@@ -104,29 +101,6 @@ func (c *Client) LastOid(ctx context.Context) (zodb.Oid, error) {
panic
(
"TODO"
)
panic
(
"TODO"
)
}
}
// decompress decompresses data according to zlib encoding.
//
// out buffer, if there is enough capacity, is used for decompression destination.
// if out has not not enough capacity a new buffer is allocated and used.
//
// return: destination buffer with full decompressed data or error.
func
decompress
(
in
[]
byte
,
out
[]
byte
)
([]
byte
,
error
)
{
bin
:=
bytes
.
NewReader
(
in
)
zr
,
err
:=
zlib
.
NewReader
(
bin
)
if
err
!=
nil
{
return
nil
,
err
}
defer
zr
.
Close
()
bout
:=
bytes
.
NewBuffer
(
out
)
_
,
err
=
io
.
Copy
(
bout
,
bin
)
if
err
!=
nil
{
return
nil
,
err
}
return
bout
.
Bytes
(),
nil
}
func
(
c
*
Client
)
Load
(
ctx
context
.
Context
,
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
func
(
c
*
Client
)
Load
(
ctx
context
.
Context
,
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
// XXX check pt is operational first? -> no if there is no data - we'll
// XXX check pt is operational first? -> no if there is no data - we'll
// just won't find ready cell
// just won't find ready cell
...
...
go/neo/client/util.go
View file @
239567f0
package
client
package
client
// misc utilities
import
(
import
(
"bytes"
"compress/zlib"
"context"
"context"
"io"
"io"
...
@@ -16,3 +19,26 @@ func lclose(ctx context.Context, c io.Closer) {
...
@@ -16,3 +19,26 @@ func lclose(ctx context.Context, c io.Closer) {
log
.
Error
(
ctx
,
err
)
log
.
Error
(
ctx
,
err
)
}
}
}
}
// decompress decompresses data according to zlib encoding.
//
// out buffer, if there is enough capacity, is used for decompression destination.
// if out has not not enough capacity a new buffer is allocated and used.
//
// return: destination buffer with full decompressed data or error.
func
decompress
(
in
[]
byte
,
out
[]
byte
)
([]
byte
,
error
)
{
bin
:=
bytes
.
NewReader
(
in
)
zr
,
err
:=
zlib
.
NewReader
(
bin
)
if
err
!=
nil
{
return
nil
,
err
}
defer
zr
.
Close
()
bout
:=
bytes
.
NewBuffer
(
out
)
_
,
err
=
io
.
Copy
(
bout
,
bin
)
if
err
!=
nil
{
return
nil
,
err
}
return
bout
.
Bytes
(),
nil
}
go/neo/connection.go
View file @
239567f0
...
@@ -365,6 +365,10 @@ func (nl *NodeLink) Accept(ctx context.Context) (c *Conn, err error) {
...
@@ -365,6 +365,10 @@ func (nl *NodeLink) Accept(ctx context.Context) (c *Conn, err error) {
}
}
return
nil
,
ErrLinkDown
return
nil
,
ErrLinkDown
// XXX for long-lived links - better to propagate ctx cancel to link.Close to
// lower cases that are run at every select.
//
// XXX see xio.CloseWhenDone() for helper for this.
// XXX ctx cancel tests
// XXX ctx cancel tests
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
return
nil
,
ctx
.
Err
()
...
...
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