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

+3
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

+1
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

+16-10
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

+1
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

+1
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

+1
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

+43
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

+5
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

+2-1
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

+1
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

database_graphs_impl.go

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (d *database) GraphExists(ctx context.Context, name string) (bool, error) {
7878

7979
type getGraphsResponse struct {
8080
Graphs []graphDefinition `json:"graphs,omitempty"`
81+
ArangoError
8182
}
8283

8384
// Graphs returns a list of all graphs in the database.

database_views_impl.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ import (
2828
)
2929

3030
type viewInfo struct {
31-
ID string `json:"id,omitempty"`
3231
Name string `json:"name,omitempty"`
3332
Type ViewType `json:"type,omitempty"`
33+
ArangoID
34+
ArangoError
3435
}
3536

3637
type getViewResponse struct {
3738
Result []viewInfo `json:"result,omitempty"`
39+
40+
ArangoError
3841
}
3942

4043
// View opens a connection to an existing view within the database.

graph_vertex_collections_impl.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
type listVertexCollectionResponse struct {
3131
Collections []string `json:"collections,omitempty"`
32+
ArangoError
3233
}
3334

3435
// VertexCollection opens a connection to an existing edge-collection within the graph.

id.go

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import (
2727
"strings"
2828
)
2929

30+
// ArangoID is a generic Arango ID struct representation
31+
type ArangoID struct {
32+
ID string `json:"id,omitempty"`
33+
GloballyUniqueId string `json:"globallyUniqueId,omitempty"`
34+
}
35+
3036
// DocumentID references a document in a collection.
3137
// Format: collection/_key
3238
type DocumentID string

meta.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ package driver
2424

2525
// DocumentMeta contains all meta data used to identifier a document.
2626
type DocumentMeta struct {
27-
Key string `json:"_key,omitempty"`
28-
ID DocumentID `json:"_id,omitempty"`
29-
Rev string `json:"_rev,omitempty"`
27+
Name string `json:"name,omitempty"`
28+
Key string `json:"_key,omitempty"`
29+
ID DocumentID `json:"_id,omitempty"`
30+
Rev string `json:"_rev,omitempty"`
31+
OldRev string `json:"_oldRev,omitempty"`
3032
}
3133

3234
// validateKey returns an error if the given key is empty otherwise invalid.

test/client_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ func createClient(t testEnv, waitUntilReady bool, disallowUnknownFields bool) dr
254254
t.Fatalf("Failed to create new client: %s", describe(err))
255255
}
256256

257+
if os.Getenv("TEST_NOT_WAIT_UNTIL_READY") != "" {
258+
waitUntilReady = false
259+
}
260+
257261
if waitUntilReady {
258262
timeout := time.Minute
259263
ctx, cancel := context.WithTimeout(context.Background(), timeout)

transaction.go

+1
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ type transactionCollectionsRequest struct {
7171
}
7272

7373
type transactionResponse struct {
74+
ArangoError
7475
Result interface{} `json:"result"`
7576
}

user_impl.go

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type userData struct {
5151
Active bool `json:"active,omitempty"`
5252
Extra *RawObject `json:"extra,omitempty"`
5353
ChangePassword bool `json:"changePassword,omitempty"`
54+
ArangoError
5455
}
5556

5657
// relPath creates the relative path to this index (`_api/user/<name>`)

view_arangosearch.go

+39-4
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,17 @@ type ArangoSearchAnalyzerDefinition struct {
247247
Type ArangoSearchAnalyzerType `json:"type,omitempty"`
248248
Properties ArangoSearchAnalyzerProperties `json:"properties,omitempty"`
249249
Features []ArangoSearchAnalyzerFeature `json:"features,omitempty"`
250+
ArangoError
250251
}
251252

252-
// ArangoSearchViewProperties contains properties an an ArangoSearch view.
253+
type ArangoSearchViewBase struct {
254+
Type ViewType `json:"type,omitempty"`
255+
Name string `json:"name,omitempty"`
256+
ArangoID
257+
ArangoError
258+
}
259+
260+
// ArangoSearchViewProperties contains properties on an ArangoSearch view.
253261
type ArangoSearchViewProperties struct {
254262
// CleanupIntervalStep specifies the minimum number of commits to wait between
255263
// removing unused files in the data directory.
@@ -294,12 +302,38 @@ type ArangoSearchViewProperties struct {
294302
WriteBufferSizeMax *int64 `json:"writebufferSizeMax,omitempty"`
295303

296304
// Links contains the properties for how individual collections
297-
// are indexed in thie view.
305+
// are indexed in the view.
298306
// The key of the map are collection names.
299307
Links ArangoSearchLinks `json:"links,omitempty"`
300308

301309
// PrimarySort describes how individual fields are sorted
302310
PrimarySort []ArangoSearchPrimarySortEntry `json:"primarySort,omitempty"`
311+
312+
// PrimarySortCompression Defines how to compress the primary sort data (introduced in v3.7.1).
313+
// ArangoDB v3.5 and v3.6 always compress the index using LZ4. This option is immutable.
314+
PrimarySortCompression PrimarySortCompression `json:"primarySortCompression,omitempty"`
315+
316+
// StoredValues An array of objects to describe which document attributes to store in the View index (introduced in v3.7.1).
317+
// It can then cover search queries, which means the data can be taken from the index directly and accessing the storage engine can be avoided.
318+
// This option is immutable.
319+
StoredValues []StoredValue `json:"storedValues,omitempty"`
320+
321+
ArangoSearchViewBase
322+
}
323+
324+
// PrimarySortCompression Defines how to compress the primary sort data (introduced in v3.7.1)
325+
type PrimarySortCompression string
326+
327+
const (
328+
// PrimarySortCompressionLz4 (default): use LZ4 fast compression.
329+
PrimarySortCompressionLz4 PrimarySortCompression = "lz4"
330+
// PrimarySortCompressionNone disable compression to trade space for speed.
331+
PrimarySortCompressionNone PrimarySortCompression = "none"
332+
)
333+
334+
type StoredValue struct {
335+
Fields []string `json:"fields,omitempty"`
336+
Compression PrimarySortCompression `json:"compression,omitempty"`
303337
}
304338

305339
// ArangoSearchSortDirection describes the sorting direction
@@ -368,10 +402,11 @@ type ArangoSearchConsolidationPolicyBytesAccum struct {
368402

369403
// ArangoSearchConsolidationPolicyTier contains fields used for ArangoSearchConsolidationPolicyTypeTier
370404
type ArangoSearchConsolidationPolicyTier struct {
405+
MinScore *int64 `json:"minScore,omitempty"`
371406
// MinSegments specifies the minimum number of segments that will be evaluated as candidates for consolidation.
372-
MinSegments *int64 `json:"minSegments,omitempty"`
407+
MinSegments *int64 `json:"segmentsMin,omitempty"`
373408
// MaxSegments specifies the maximum number of segments that will be evaluated as candidates for consolidation.
374-
MaxSegments *int64 `json:"maxSegments,omitempty"`
409+
MaxSegments *int64 `json:"segmentsMax,omitempty"`
375410
// SegmentsBytesMax specifies the maxinum allowed size of all consolidated segments in bytes.
376411
SegmentsBytesMax *int64 `json:"segmentsBytesMax,omitempty"`
377412
// SegmentsBytesFloor defines the value (in bytes) to treat all smaller segments as equal for consolidation selection.

0 commit comments

Comments
 (0)