Skip to content

Commit 344c139

Browse files
authored
Add missing fields (#367)
* Add missing fields * TEST_NOT_WAIT_UNTIL_READY * Generic type for State field * Add custom unmarshall for State
1 parent 11421c3 commit 344c139

19 files changed

+136
-19
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ __test_go_test:
370370
--net=$(TEST_NET) \
371371
-v "${ROOTDIR}":/usr/code ${TEST_RESOURCES_VOLUME} \
372372
-e TEST_ENDPOINTS=$(TEST_ENDPOINTS) \
373+
-e TEST_NOT_WAIT_UNTIL_READY=$(TEST_NOT_WAIT_UNTIL_READY) \
373374
-e TEST_AUTHENTICATION=$(TEST_AUTHENTICATION) \
374375
-e TEST_JWTSECRET=$(TEST_JWTSECRET) \
375376
-e TEST_CONNECTION=$(TEST_CONNECTION) \
@@ -397,6 +398,7 @@ __test_v2_go_test:
397398
--net=$(TEST_NET) \
398399
-v "${ROOTDIR}":/usr/code:ro ${TEST_RESOURCES_VOLUME} \
399400
-e TEST_ENDPOINTS=$(TEST_ENDPOINTS) \
401+
-e TEST_NOT_WAIT_UNTIL_READY=$(TEST_NOT_WAIT_UNTIL_READY) \
400402
-e TEST_AUTHENTICATION=$(TEST_AUTHENTICATION) \
401403
-e TEST_JWTSECRET=$(TEST_JWTSECRET) \
402404
-e TEST_MODE=$(TEST_MODE) \
@@ -458,6 +460,7 @@ run-tests-cluster-failover:
458460
--privileged \
459461
-v "${ROOTDIR}":/usr/code \
460462
-e TEST_ENDPOINTS=http://127.0.0.1:7001,http://127.0.0.1:7006,http://127.0.0.1:7011 \
463+
-e TEST_NOT_WAIT_UNTIL_READY=$(TEST_NOT_WAIT_UNTIL_READY) \
461464
-e TEST_AUTHENTICATION=basic:root: \
462465
-e GODEBUG=tls13=1 \
463466
-w /usr/code/ \

client_databases_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (c *client) DatabaseExists(ctx context.Context, name string) (bool, error)
7171

7272
type getDatabaseResponse struct {
7373
Result []string `json:"result,omitempty"`
74+
ArangoError
7475
}
7576

7677
// Databases returns a list of all databases found by the client.

client_server_admin.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type ServerStatistics struct {
7575
ClientUser ClientStats `json:"clientUser,omitempty"`
7676
HTTP HTTPStats `json:"http"`
7777
Server ServerStats `json:"server"`
78+
ArangoError
7879
}
7980

8081
// SystemStats contains statistical data about the system, this is part of
@@ -110,16 +111,18 @@ type ClientStats struct {
110111

111112
// HTTPStats contains statistics about the HTTP traffic.
112113
type HTTPStats struct {
113-
RequestsTotal int64 `json:"requestsTotal"`
114-
RequestsAsync int64 `json:"requestsAsync"`
115-
RequestsGet int64 `json:"requestsGet"`
116-
RequestsHead int64 `json:"requestsHead"`
117-
RequestsPost int64 `json:"requestsPost"`
118-
RequestsPut int64 `json:"requestsPut"`
119-
RequestsPatch int64 `json:"requestsPatch"`
120-
RequestsDelete int64 `json:"requestsDelete"`
121-
RequestsOptions int64 `json:"requestsOptions"`
122-
RequestsOther int64 `json:"requestsOther"`
114+
RequestsTotal int64 `json:"requestsTotal"`
115+
RequestsAsync int64 `json:"requestsAsync"`
116+
RequestsGet int64 `json:"requestsGet"`
117+
RequestsHead int64 `json:"requestsHead"`
118+
RequestsPost int64 `json:"requestsPost"`
119+
RequestsPut int64 `json:"requestsPut"`
120+
RequestsPatch int64 `json:"requestsPatch"`
121+
RequestsDelete int64 `json:"requestsDelete"`
122+
RequestsOptions int64 `json:"requestsOptions"`
123+
RequestsOther int64 `json:"requestsOther"`
124+
RequestsSuperuser int64 `json:"requestsSuperuser,omitempty"`
125+
RequestsUser int64 `json:"requestsUser,omitempty"`
123126
}
124127

125128
// TransactionStats contains statistics about transactions.
@@ -128,6 +131,7 @@ type TransactionStats struct {
128131
Aborted int64 `json:"aborted"`
129132
Committed int64 `json:"committed"`
130133
IntermediateCommits int64 `json:"intermediateCommits"`
134+
ReadOnly int64 `json:"readOnly,omitempty"`
131135
}
132136

133137
// MemoryStats contains statistics about memory usage.
@@ -137,6 +141,7 @@ type MemoryStats struct {
137141
CountOfTimes int64 `json:"countOfTimes"`
138142
HeapMax int64 `json:"heapMax"`
139143
HeapMin int64 `json:"heapMin"`
144+
Invocations int64 `json:"invocations,omitempty"`
140145
}
141146

142147
// V8ContextStats contains statistics about V8 contexts.
@@ -145,6 +150,7 @@ type V8ContextStats struct {
145150
Busy int64 `json:"busy"`
146151
Dirty int64 `json:"dirty"`
147152
Free int64 `json:"free"`
153+
Min int64 `json:"min,omitempty"`
148154
Max int64 `json:"max"`
149155
Memory []MemoryStats `json:"memory"`
150156
}

client_server_admin_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
type serverModeResponse struct {
3030
Mode ServerMode `json:"mode"`
31+
ArangoError
3132
}
3233

3334
type serverModeRequest struct {

client_server_info_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type roleResponse struct {
5252
// Role of the server within a cluster
5353
Role string `json:"role,omitempty"`
5454
Mode string `json:"mode,omitempty"`
55+
ArangoError
5556
}
5657

5758
// asServerRole converts the response into a ServerRole

client_users_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (c *client) UserExists(ctx context.Context, name string) (bool, error) {
7575

7676
type listUsersResponse struct {
7777
Result []userData `json:"result,omitempty"`
78+
ArangoError
7879
}
7980

8081
// Users returns a list of all users found by the client.

cluster.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ package driver
2424

2525
import (
2626
"context"
27+
"encoding/json"
28+
"fmt"
29+
"reflect"
2730
"time"
2831
)
2932

@@ -123,6 +126,46 @@ type DatabaseInventory struct {
123126
Collections []InventoryCollection `json:"collections,omitempty"`
124127
// Details of all views
125128
Views []InventoryView `json:"views,omitempty"`
129+
State State `json:"state,omitempty"`
130+
Tick string `json:"tick,omitempty"`
131+
}
132+
133+
type State struct {
134+
Running bool `json:"running,omitempty"`
135+
LastLogTick string `json:"lastLogTick,omitempty"`
136+
LastUncommittedLogTick string `json:"lastUncommittedLogTick,omitempty"`
137+
TotalEvents int64 `json:"totalEvents,omitempty"`
138+
Time time.Time `json:"time,omitempty"`
139+
}
140+
141+
// UnmarshalJSON marshals State to arangodb json representation
142+
func (s *State) UnmarshalJSON(d []byte) error {
143+
var internal interface{}
144+
145+
if err := json.Unmarshal(d, &internal); err != nil {
146+
return err
147+
}
148+
149+
if val, ok := internal.(string); ok {
150+
if val != "unused" {
151+
fmt.Printf("unrecognized State value: %s\n", val)
152+
}
153+
*s = State{}
154+
return nil
155+
} else {
156+
type Alias State
157+
out := Alias{}
158+
159+
if err := json.Unmarshal(d, &out); err != nil {
160+
return &json.UnmarshalTypeError{
161+
Value: string(d),
162+
Type: reflect.TypeOf(s).Elem(),
163+
}
164+
}
165+
*s = State(out)
166+
}
167+
168+
return nil
126169
}
127170

128171
// IsReady returns true if the IsReady flag of all collections is set.

collection_documents.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,9 @@ type ImportDocumentStatistics struct {
170170
Updated int64 `json:"updated,omitempty"`
171171
// Ignored holds the number of failed but ignored insert operations (in case onDuplicate was set to ignore).
172172
Ignored int64 `json:"ignored,omitempty"`
173+
// if query parameter details is set to true, the result will contain a details attribute which is an array
174+
// with more detailed information about which documents could not be inserted.
175+
Details []string
176+
177+
ArangoError
173178
}

database.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@ func (t EngineType) String() string {
103103

104104
// EngineInfo contains information about the database engine being used.
105105
type EngineInfo struct {
106-
Type EngineType `json:"name"`
106+
Type EngineType `json:"name"`
107+
Supports map[string]interface{} `json:"supports,omitempty"`
107108
}

database_arangosearch_analyzers_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func (d *database) Analyzer(ctx context.Context, name string) (ArangoSearchAnaly
150150

151151
type analyzerListResponse struct {
152152
Analyzer []ArangoSearchAnalyzerDefinition `json:"result,omitempty"`
153+
ArangoError
153154
}
154155

155156
// List returns a list of all analyzers

0 commit comments

Comments
 (0)