From cdbdaf6404f5011de052405a46e1963c4a964ad7 Mon Sep 17 00:00:00 2001 From: Ewout Prangsma Date: Tue, 21 Aug 2018 07:58:10 +0200 Subject: [PATCH] Updated go-certificates & go-driver --- .../go-certificates/keyfile.go | 77 ++++++++-- .../arangodb/go-driver/CHANGELOG.md | 133 ++++++++++++++++++ .../arangodb/go-driver/MAINTAINERS.md | 11 ++ deps/github.com/arangodb/go-driver/Makefile | 11 ++ .../go-driver/database_collections.go | 4 +- .../arangodb/go-driver/database_graphs.go | 2 +- .../arangodb/go-driver/http/connection.go | 27 +++- deps/github.com/arangodb/go-driver/query.go | 2 +- .../arangodb/go-driver/vst/authentication.go | 2 +- .../arangodb/go-driver/vst/connection.go | 2 +- .../go-driver/vst/protocol/connection.go | 4 +- .../go-driver/vst/protocol/transport.go | 2 +- .../arangodb/go-driver/vst/response.go | 5 +- 13 files changed, 255 insertions(+), 27 deletions(-) create mode 100644 deps/github.com/arangodb/go-driver/CHANGELOG.md create mode 100644 deps/github.com/arangodb/go-driver/MAINTAINERS.md diff --git a/deps/github.com/arangodb-helper/go-certificates/keyfile.go b/deps/github.com/arangodb-helper/go-certificates/keyfile.go index 1f57e2c9..376d080d 100644 --- a/deps/github.com/arangodb-helper/go-certificates/keyfile.go +++ b/deps/github.com/arangodb-helper/go-certificates/keyfile.go @@ -38,14 +38,13 @@ import ( "strings" ) -// LoadKeyFile loads a SSL keyfile formatted for the arangod server. -func LoadKeyFile(keyFile string) (tls.Certificate, error) { - raw, err := ioutil.ReadFile(keyFile) - if err != nil { - return tls.Certificate{}, maskAny(err) - } +// Keyfile contains 1 or more certificates and a private key. +type Keyfile tls.Certificate - result := tls.Certificate{} +// NewKeyfile creates a keyfile from given content. +func NewKeyfile(content string) (Keyfile, error) { + raw := []byte(content) + result := Keyfile{} for { var derBlock *pem.Block derBlock, raw = pem.Decode(raw) @@ -56,22 +55,74 @@ func LoadKeyFile(keyFile string) (tls.Certificate, error) { result.Certificate = append(result.Certificate, derBlock.Bytes) } else if derBlock.Type == "PRIVATE KEY" || strings.HasSuffix(derBlock.Type, " PRIVATE KEY") { if result.PrivateKey == nil { + var err error result.PrivateKey, err = parsePrivateKey(derBlock.Bytes) if err != nil { - return tls.Certificate{}, maskAny(err) + return Keyfile{}, maskAny(err) } } } } + return result, nil +} - if len(result.Certificate) == 0 { - return tls.Certificate{}, maskAny(fmt.Errorf("No certificates found in %s", keyFile)) +// Validate the contents of the keyfile +func (kf Keyfile) Validate() error { + if len(kf.Certificate) == 0 { + return maskAny(fmt.Errorf("No certificates found in keyfile")) } - if result.PrivateKey == nil { - return tls.Certificate{}, maskAny(fmt.Errorf("No private key found in %s", keyFile)) + if kf.PrivateKey == nil { + return maskAny(fmt.Errorf("No private key found in keyfile")) } - return result, nil + return nil +} + +// EncodeCACertificates extracts the CA certificate(s) from the given keyfile (if any). +func (kf Keyfile) EncodeCACertificates() (string, error) { + buf := &bytes.Buffer{} + for _, derBytes := range kf.Certificate { + c, err := x509.ParseCertificate(derBytes) + if err != nil { + return "", maskAny(err) + } + if c.IsCA { + pem.Encode(buf, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) + } + } + + return buf.String(), nil +} + +// EncodeCertificates extracts all certificates from the given keyfile and encodes them as PEM blocks. +func (kf Keyfile) EncodeCertificates() string { + buf := &bytes.Buffer{} + for _, derBytes := range kf.Certificate { + pem.Encode(buf, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) + } + + return buf.String() +} + +// EncodePrivateKey extract the private key from the given keyfile and encodes is as PEM block. +func (kf Keyfile) EncodePrivateKey() string { + buf := &bytes.Buffer{} + pem.Encode(buf, pemBlockForKey(kf.PrivateKey)) + return buf.String() +} + +// LoadKeyFile loads a SSL keyfile formatted for the arangod server. +func LoadKeyFile(keyFile string) (tls.Certificate, error) { + raw, err := ioutil.ReadFile(keyFile) + if err != nil { + return tls.Certificate{}, maskAny(err) + } + + kf, err := NewKeyfile(string(raw)) + if err != nil { + return tls.Certificate{}, maskAny(err) + } + return tls.Certificate(kf), nil } // ExtractCACertificateFromKeyFile loads a SSL keyfile formatted for the arangod server and diff --git a/deps/github.com/arangodb/go-driver/CHANGELOG.md b/deps/github.com/arangodb/go-driver/CHANGELOG.md new file mode 100644 index 00000000..239819a3 --- /dev/null +++ b/deps/github.com/arangodb/go-driver/CHANGELOG.md @@ -0,0 +1,133 @@ +# Change Log + +## [Master](https://github.com/arangodb/go-driver/tree/HEAD) + +**Closed issues:** + +- Structs with key specified don't read the key [\#138](https://github.com/arangodb/go-driver/issues/138) +- Edge document with user provided key is inserted as many times as the number of shards [\#137](https://github.com/arangodb/go-driver/issues/137) +- Query "return null" make the panic: runtime error [\#117](https://github.com/arangodb/go-driver/issues/117) +- driver does not seem to decode numeric timestamps to time.Time [\#102](https://github.com/arangodb/go-driver/issues/102) +- stable and full feature? [\#100](https://github.com/arangodb/go-driver/issues/100) +- collection with "Wait for sync:" setting, Create-/UpdateDocument return: ArangoError: Code 0, ErrorNum 0 [\#96](https://github.com/arangodb/go-driver/issues/96) +- Error when connecting to ArangoDB with SSL enabled [\#95](https://github.com/arangodb/go-driver/issues/95) +- Possible concurrency issues, using VST connection [\#86](https://github.com/arangodb/go-driver/issues/86) +- An example of a transactional request [\#84](https://github.com/arangodb/go-driver/issues/84) +- Multi-tenancy connection management [\#83](https://github.com/arangodb/go-driver/issues/83) +- Cursor returned from a query with empty Count [\#82](https://github.com/arangodb/go-driver/issues/82) +- CONTRIBUTING.md [\#79](https://github.com/arangodb/go-driver/issues/79) +- Querying documents + [\#76](https://github.com/arangodb/go-driver/issues/76) +- Is there an ArangoDB-Object on Struct? [\#75](https://github.com/arangodb/go-driver/issues/75) +- DB Session [\#73](https://github.com/arangodb/go-driver/issues/73) +- correct way to get multiple documents ? [\#70](https://github.com/arangodb/go-driver/issues/70) +- Revalidate whether workaround can be removed [\#68](https://github.com/arangodb/go-driver/issues/68) +- Makefile `SWTSECRET` vs `JWTSECRET` [\#66](https://github.com/arangodb/go-driver/issues/66) +- Implement transactions [\#56](https://github.com/arangodb/go-driver/issues/56) +- bulk import API [\#55](https://github.com/arangodb/go-driver/issues/55) +- Question: how to write auto-inc feild? [\#51](https://github.com/arangodb/go-driver/issues/51) +- add index attribute for new feature in arangodb3.2 [\#48](https://github.com/arangodb/go-driver/issues/48) +- Unable to connect to server in macos [\#41](https://github.com/arangodb/go-driver/issues/41) +- Handle 401 status code before checking content type. [\#38](https://github.com/arangodb/go-driver/issues/38) +- Support for raw string in query return [\#37](https://github.com/arangodb/go-driver/issues/37) +- \[ArangoDB Server 3.1.6\] Unsupported content type: client.DatabaseExists when Database already exists [\#36](https://github.com/arangodb/go-driver/issues/36) +- Can't connect because of 'Unsupported content type'? [\#35](https://github.com/arangodb/go-driver/issues/35) +- cursor implementation when running queries with non-Document return values [\#20](https://github.com/arangodb/go-driver/issues/20) +- Make failover with cursors more explicit [\#16](https://github.com/arangodb/go-driver/issues/16) +- Add non-context version of method calls [\#7](https://github.com/arangodb/go-driver/issues/7) + +**Merged pull requests:** + +- Properly closing idle VST connections [\#139](https://github.com/arangodb/go-driver/pull/139) +- Improving performance of reading the body of large responses [\#134](https://github.com/arangodb/go-driver/pull/134) +- Added Collection.ReadDocuments [\#133](https://github.com/arangodb/go-driver/pull/133) +- Added support for fetching job ID in CleanoutServer [\#131](https://github.com/arangodb/go-driver/pull/131) +- Exclude high load test on VST+3.2 [\#129](https://github.com/arangodb/go-driver/pull/129) +- Test/prevent concurrent vst read write [\#128](https://github.com/arangodb/go-driver/pull/128) +- Added single+ssl tests. All tests now use starter [\#127](https://github.com/arangodb/go-driver/pull/127) +- Bugfix/read chunk loop [\#126](https://github.com/arangodb/go-driver/pull/126) +- Prevent possible endless read chunk look in in VST connection [\#125](https://github.com/arangodb/go-driver/pull/125) +- Fixing Query\(return nul\) resulting in panic [\#124](https://github.com/arangodb/go-driver/pull/124) +- Added WithAllowNoLeader [\#123](https://github.com/arangodb/go-driver/pull/123) +- Added Cluster.RemoveServer [\#122](https://github.com/arangodb/go-driver/pull/122) +- Added mutex guarding message chunks. [\#121](https://github.com/arangodb/go-driver/pull/121) +- Documentation/go refactor [\#120](https://github.com/arangodb/go-driver/pull/120) +- VST stream cursor test fixes & VST fail-quick fix [\#119](https://github.com/arangodb/go-driver/pull/119) +- Prevent a VST connection from being used before its configuration callback has finished [\#118](https://github.com/arangodb/go-driver/pull/118) +- Fixed AgencyConnection in the context of authentication [\#116](https://github.com/arangodb/go-driver/pull/116) +- Adding timeout for streaming cursor test [\#115](https://github.com/arangodb/go-driver/pull/115) +- Added package level docs [\#114](https://github.com/arangodb/go-driver/pull/114) +- Close the connection when the initial onCreatedCallback fails [\#113](https://github.com/arangodb/go-driver/pull/113) +- Adding extra concurrency-safety for VST [\#112](https://github.com/arangodb/go-driver/pull/112) +- Added upper limit to the number of concurrent requests to a single server. [\#111](https://github.com/arangodb/go-driver/pull/111) +- Added support for multiple VST connections per server [\#110](https://github.com/arangodb/go-driver/pull/110) +- Fixed expected status code for operations on collections that have waitForSync enabled [\#109](https://github.com/arangodb/go-driver/pull/109) +- Added helper to determine agency health [\#108](https://github.com/arangodb/go-driver/pull/108) +- Added ServerID function [\#107](https://github.com/arangodb/go-driver/pull/107) +- Added exclusive lock using agency [\#106](https://github.com/arangodb/go-driver/pull/106) +- Added helper for JWT secret based authentication [\#105](https://github.com/arangodb/go-driver/pull/105) +- Added Agency API [\#104](https://github.com/arangodb/go-driver/pull/104) +- Added option to not follow redirects and return the original response [\#103](https://github.com/arangodb/go-driver/pull/103) +- Add support for stream query cursor [\#101](https://github.com/arangodb/go-driver/pull/101) +- Active-Failover with Velocystream [\#99](https://github.com/arangodb/go-driver/pull/99) +- Added API functions for shutting down a server and cleaning it out [\#98](https://github.com/arangodb/go-driver/pull/98) +- Skip replication test on cluster [\#94](https://github.com/arangodb/go-driver/pull/94) +- Documented behavior for custom http.Transport wrt MaxIdleConnsPerHost field [\#93](https://github.com/arangodb/go-driver/pull/93) +- Fix ReturnOld/New for edge/vertex operations. [\#92](https://github.com/arangodb/go-driver/pull/92) +- Database.Info\(\) added [\#91](https://github.com/arangodb/go-driver/pull/91) +- Replication interface added. [\#90](https://github.com/arangodb/go-driver/pull/90) +- Grouping server specific info calls in ClientServerInfo, exposing ServerRole API [\#89](https://github.com/arangodb/go-driver/pull/89) +- Added `ReplicationFactor` to `SetCollectionPropertiesOptions` [\#88](https://github.com/arangodb/go-driver/pull/88) +- Allow for some time to reach intended status [\#87](https://github.com/arangodb/go-driver/pull/87) +- Fixing SWTSECRET -\> JWTSECRET [\#85](https://github.com/arangodb/go-driver/pull/85) +- Added CONTRIBUTING.md [\#80](https://github.com/arangodb/go-driver/pull/80) +- Resilientsingle support [\#77](https://github.com/arangodb/go-driver/pull/77) +- Adding cluster specific operations [\#72](https://github.com/arangodb/go-driver/pull/72) +- Added IsSmart, SmartGraphAttribute attributes to CreateCollectionOptions [\#71](https://github.com/arangodb/go-driver/pull/71) +- Adding Response.Header\(string\) & tests [\#69](https://github.com/arangodb/go-driver/pull/69) +- Server mode \(get/set\) [\#65](https://github.com/arangodb/go-driver/pull/65) +- Adding `WithConfigured` [\#64](https://github.com/arangodb/go-driver/pull/64) +- Added DistributeShardsLike field to CreateCollectionOptions [\#62](https://github.com/arangodb/go-driver/pull/62) +- Added WithEnforceReplicationFactor [\#61](https://github.com/arangodb/go-driver/pull/61) +- Added `WithIsSystem` [\#60](https://github.com/arangodb/go-driver/pull/60) +- Support synchronising endpoints on resilient single server mode [\#59](https://github.com/arangodb/go-driver/pull/59) +- Added `WithIgnoreRevisions` [\#58](https://github.com/arangodb/go-driver/pull/58) +- Basic transaction implementation [\#57](https://github.com/arangodb/go-driver/pull/57) +- Support `x-arango-dump` content type [\#54](https://github.com/arangodb/go-driver/pull/54) +- Added WithIsRestore \(not internal for normal client use!!!!\) [\#53](https://github.com/arangodb/go-driver/pull/53) +- Raw authentication [\#52](https://github.com/arangodb/go-driver/pull/52) +- Include travis tests for arangodb 3.1 [\#50](https://github.com/arangodb/go-driver/pull/50) +- Added NoDeduplicate field for hash & skiplist index options [\#49](https://github.com/arangodb/go-driver/pull/49) +- Supporting additional user access functions [\#47](https://github.com/arangodb/go-driver/pull/47) +- ftKnox - fix sprintf conversions [\#42](https://github.com/arangodb/go-driver/pull/42) +- Convert 401 text/plain response to proper ArangoError [\#39](https://github.com/arangodb/go-driver/pull/39) +- Adding Storage engine detection [\#34](https://github.com/arangodb/go-driver/pull/34) +- Starter update [\#33](https://github.com/arangodb/go-driver/pull/33) +- Fix reading the response body to ensure keep-alive [\#32](https://github.com/arangodb/go-driver/pull/32) +- Velocy stream support \(wip\) [\#31](https://github.com/arangodb/go-driver/pull/31) +- Supporting Velocypack content-type \(instead of JSON\) \(wip\) [\#29](https://github.com/arangodb/go-driver/pull/29) +- Fixed Cursor.ReadDocument for queries returning non-documents [\#27](https://github.com/arangodb/go-driver/pull/27) +- Added Collection.Statistics [\#25](https://github.com/arangodb/go-driver/pull/25) +- Adding Database.ValidateQuery [\#24](https://github.com/arangodb/go-driver/pull/24) +- Added Collection.DocumentExists [\#23](https://github.com/arangodb/go-driver/pull/23) +- Added `Database.Remove\(\)` [\#22](https://github.com/arangodb/go-driver/pull/22) +- Changing graph API to introduce VertexConstraints [\#21](https://github.com/arangodb/go-driver/pull/21) +- Endpoint reconfiguration [\#19](https://github.com/arangodb/go-driver/pull/19) +- Allow custom http.RoundTripper [\#18](https://github.com/arangodb/go-driver/pull/18) +- Added WithEndpoint, used to force a specific endpoint for a request. [\#17](https://github.com/arangodb/go-driver/pull/17) +- Adding failover tests [\#15](https://github.com/arangodb/go-driver/pull/15) +- Adding simple performance benchmarks [\#14](https://github.com/arangodb/go-driver/pull/14) +- Cluster tests [\#12](https://github.com/arangodb/go-driver/pull/12) +- ImportDocuments [\#11](https://github.com/arangodb/go-driver/pull/11) +- Adding Graph support \(wip\) [\#10](https://github.com/arangodb/go-driver/pull/10) +- Added collection status,count,rename,load,unload,truncate,properties [\#9](https://github.com/arangodb/go-driver/pull/9) +- Adding user API [\#8](https://github.com/arangodb/go-driver/pull/8) +- Adding index support [\#6](https://github.com/arangodb/go-driver/pull/6) +- Added Cursor support [\#5](https://github.com/arangodb/go-driver/pull/5) +- Adding multi document requests [\#4](https://github.com/arangodb/go-driver/pull/4) +- Creating interface. \(WIP\) [\#3](https://github.com/arangodb/go-driver/pull/3) +- Revert "Creating interface" [\#2](https://github.com/arangodb/go-driver/pull/2) +- Creating interface [\#1](https://github.com/arangodb/go-driver/pull/1) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/deps/github.com/arangodb/go-driver/MAINTAINERS.md b/deps/github.com/arangodb/go-driver/MAINTAINERS.md new file mode 100644 index 00000000..7e368ad5 --- /dev/null +++ b/deps/github.com/arangodb/go-driver/MAINTAINERS.md @@ -0,0 +1,11 @@ +# Maintainer Instructions + +- Always preserve backward compatibility +- Build using `make clean && make` +- After merging PR, alway run `make changelog` and commit changes +- Set ArangoDB docker container (used for testing) using `export ARANGODB=` +- Run tests using: + - `make run-tests-single` + - `make run-tests-resilientsingle` + - `make run-tests-cluster`. +- Always create changes in a PR diff --git a/deps/github.com/arangodb/go-driver/Makefile b/deps/github.com/arangodb/go-driver/Makefile index b8f6f00d..d49c309e 100644 --- a/deps/github.com/arangodb/go-driver/Makefile +++ b/deps/github.com/arangodb/go-driver/Makefile @@ -113,6 +113,17 @@ $(GOBUILDDIR): GOPATH=$(GOBUILDDIR) go get github.com/arangodb/go-velocypack GOPATH=$(GOBUILDDIR) go get github.com/dgrijalva/jwt-go +.PHONY: changelog +changelog: + @docker run --rm \ + -e CHANGELOG_GITHUB_TOKEN=$(shell cat ~/.arangodb/github-token) \ + -v "$(ROOTDIR)":/usr/local/src/your-app \ + ferrarimarco/github-changelog-generator \ + --user arangodb \ + --project go-driver \ + --no-author \ + --unreleased-label "Master" + run-tests: run-tests-http run-tests-single run-tests-resilientsingle run-tests-cluster # Tests of HTTP package diff --git a/deps/github.com/arangodb/go-driver/database_collections.go b/deps/github.com/arangodb/go-driver/database_collections.go index 41989f92..9e8645b0 100644 --- a/deps/github.com/arangodb/go-driver/database_collections.go +++ b/deps/github.com/arangodb/go-driver/database_collections.go @@ -89,11 +89,11 @@ type CreateCollectionOptions struct { // This field is used for internal purposes only. DO NOT USE. DistributeShardsLike string `json:"distributeShardsLike,omitempty"` // Set to create a smart edge or vertex collection. - // This requires ArangoDB enterprise. + // This requires ArangoDB Enterprise Edition. IsSmart bool `json:"isSmart,omitempty"` // This field must be set to the attribute that will be used for sharding or smart graphs. // All vertices are required to have this attribute set. Edges derive the attribute from their connected vertices. - // This requires ArangoDB enterprise. + // This requires ArangoDB Enterprise Edition. SmartGraphAttribute string `json:"smartGraphAttribute,omitempty"` } diff --git a/deps/github.com/arangodb/go-driver/database_graphs.go b/deps/github.com/arangodb/go-driver/database_graphs.go index 899f5445..a45edda6 100644 --- a/deps/github.com/arangodb/go-driver/database_graphs.go +++ b/deps/github.com/arangodb/go-driver/database_graphs.go @@ -49,7 +49,7 @@ type CreateGraphOptions struct { // EdgeDefinitions is an array of edge definitions for the graph. EdgeDefinitions []EdgeDefinition // IsSmart defines if the created graph should be smart. - // This only has effect in Enterprise version. + // This only has effect in Enterprise Edition. IsSmart bool // SmartGraphAttribute is the attribute name that is used to smartly shard the vertices of a graph. // Every vertex in this Graph has to have this attribute. diff --git a/deps/github.com/arangodb/go-driver/http/connection.go b/deps/github.com/arangodb/go-driver/http/connection.go index e4c42889..aa4e3bf0 100644 --- a/deps/github.com/arangodb/go-driver/http/connection.go +++ b/deps/github.com/arangodb/go-driver/http/connection.go @@ -23,6 +23,7 @@ package http import ( + "bytes" "context" "crypto/tls" "encoding/json" @@ -273,8 +274,7 @@ func (c *httpConnection) Do(ctx context.Context, req driver.Request) (driver.Res } // Read response body - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := readBody(resp) if err != nil { return nil, driver.WithStack(err) } @@ -319,6 +319,29 @@ func (c *httpConnection) Do(ctx context.Context, req driver.Request) (driver.Res return httpResp, nil } +// readBody reads the body of the given response into a byte slice. +func readBody(resp *http.Response) ([]byte, error) { + defer resp.Body.Close() + contentLength := resp.ContentLength + if contentLength < 0 { + // Don't know the content length, do it the slowest way + result, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, driver.WithStack(err) + } + return result, nil + } + buf := &bytes.Buffer{} + if int64(int(contentLength)) == contentLength { + // contentLength is an int64. If we can safely cast to int, use Grow. + buf.Grow(int(contentLength)) + } + if _, err := buf.ReadFrom(resp.Body); err != nil { + return nil, driver.WithStack(err) + } + return buf.Bytes(), nil +} + // Unmarshal unmarshals the given raw object into the given result interface. func (c *httpConnection) Unmarshal(data driver.RawObject, result interface{}) error { ct := c.contentType diff --git a/deps/github.com/arangodb/go-driver/query.go b/deps/github.com/arangodb/go-driver/query.go index 47c5a2cf..ee3d6f10 100644 --- a/deps/github.com/arangodb/go-driver/query.go +++ b/deps/github.com/arangodb/go-driver/query.go @@ -131,7 +131,7 @@ type queryRequest struct { // A list of to-be-included or to-be-excluded optimizer rules can be put into this attribute, telling the optimizer to include or exclude specific rules. // To disable a rule, prefix its name with a -, to enable a rule, prefix it with a +. There is also a pseudo-rule all, which will match all optimizer rules. OptimizerRules string `json:"optimizer.rules,omitempty"` - // This enterprise parameter allows to configure how long a DBServer will have time to bring the satellite collections + // This Enterprise Edition parameter allows to configure how long a DBServer will have time to bring the satellite collections // involved in the query into sync. The default value is 60.0 (seconds). When the max time has been reached the query will be stopped. SatelliteSyncWait float64 `json:"satelliteSyncWait,omitempty"` // if set to true and the query contains a LIMIT clause, then the result will have an extra attribute with the sub-attributes diff --git a/deps/github.com/arangodb/go-driver/vst/authentication.go b/deps/github.com/arangodb/go-driver/vst/authentication.go index 97a66dab..4a9d4de4 100644 --- a/deps/github.com/arangodb/go-driver/vst/authentication.go +++ b/deps/github.com/arangodb/go-driver/vst/authentication.go @@ -141,7 +141,7 @@ func (a *vstAuthenticationImpl) PrepareFunc(vstConn *vstConnection) func(ctx con // Wait for response m := <-respChan - resp, err := newResponse(m, "", nil) + resp, err := newResponse(m.Data, "", nil) if err != nil { return driver.WithStack(err) } diff --git a/deps/github.com/arangodb/go-driver/vst/connection.go b/deps/github.com/arangodb/go-driver/vst/connection.go index cb8254d3..456ca6b1 100644 --- a/deps/github.com/arangodb/go-driver/vst/connection.go +++ b/deps/github.com/arangodb/go-driver/vst/connection.go @@ -183,7 +183,7 @@ func (c *vstConnection) do(ctx context.Context, req driver.Request, transport me } } - vstResp, err := newResponse(msg, c.endpoint.String(), rawResponse) + vstResp, err := newResponse(msg.Data, c.endpoint.String(), rawResponse) if err != nil { fmt.Printf("Cannot decode msg %d: %#v\n", msg.ID, err) return nil, driver.WithStack(err) diff --git a/deps/github.com/arangodb/go-driver/vst/protocol/connection.go b/deps/github.com/arangodb/go-driver/vst/protocol/connection.go index d1af33c4..71b57853 100644 --- a/deps/github.com/arangodb/go-driver/vst/protocol/connection.go +++ b/deps/github.com/arangodb/go-driver/vst/protocol/connection.go @@ -230,7 +230,7 @@ func (c *Connection) readChunkLoop() { if err != nil { if !c.IsClosed() { // Handle error - if err == io.EOF { + if driver.Cause(err) == io.EOF { // Connection closed c.Close() } else { @@ -286,5 +286,5 @@ func (c *Connection) updateLastActivity() { // IsIdle returns true when the last activity was more than the given timeout ago. func (c *Connection) IsIdle(idleTimeout time.Duration) bool { - return time.Since(c.lastActivity) > idleTimeout + return time.Since(c.lastActivity) > idleTimeout && c.msgStore.Size() == 0 } diff --git a/deps/github.com/arangodb/go-driver/vst/protocol/transport.go b/deps/github.com/arangodb/go-driver/vst/protocol/transport.go index 36192c88..10542818 100644 --- a/deps/github.com/arangodb/go-driver/vst/protocol/transport.go +++ b/deps/github.com/arangodb/go-driver/vst/protocol/transport.go @@ -228,7 +228,7 @@ func (c *Transport) createConnection() (*Connection, error) { func (c *Transport) cleanup() { for { time.Sleep(c.IdleConnTimeout / 10) - remaining, _ := c.CloseIdleConnections() + _, remaining := c.CloseIdleConnections() if remaining == 0 { return } diff --git a/deps/github.com/arangodb/go-driver/vst/response.go b/deps/github.com/arangodb/go-driver/vst/response.go index e290e6c1..2beb225b 100644 --- a/deps/github.com/arangodb/go-driver/vst/response.go +++ b/deps/github.com/arangodb/go-driver/vst/response.go @@ -28,7 +28,6 @@ import ( "sync" driver "github.com/arangodb/go-driver" - "github.com/arangodb/go-driver/vst/protocol" velocypack "github.com/arangodb/go-velocypack" ) @@ -46,9 +45,9 @@ type vstResponse struct { } // newResponse builds a vstResponse from given message. -func newResponse(msg protocol.Message, endpoint string, rawResponse *[]byte) (*vstResponse, error) { +func newResponse(msgData []byte, endpoint string, rawResponse *[]byte) (*vstResponse, error) { // Decode header - hdr := velocypack.Slice(msg.Data) + hdr := velocypack.Slice(msgData) if err := hdr.AssertType(velocypack.Array); err != nil { return nil, driver.WithStack(err) }