|
1 | 1 | //
|
2 | 2 | // DISCLAIMER
|
3 | 3 | //
|
4 |
| -// Copyright 2017 ArangoDB GmbH, Cologne, Germany |
| 4 | +// Copyright 2017-2021 ArangoDB GmbH, Cologne, Germany |
5 | 5 | //
|
6 | 6 | // Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | // you may not use this file except in compliance with the License.
|
|
18 | 18 | // Copyright holder is ArangoDB GmbH, Cologne, Germany
|
19 | 19 | //
|
20 | 20 | // Author Ewout Prangsma
|
| 21 | +// Author Tomasz Mielech |
21 | 22 | //
|
22 | 23 |
|
23 | 24 | package driver
|
@@ -55,10 +56,13 @@ type Collection interface {
|
55 | 56 | // SetProperties changes properties of the collection.
|
56 | 57 | SetProperties(ctx context.Context, options SetCollectionPropertiesOptions) error
|
57 | 58 |
|
| 59 | + // Shards fetches shards information of the collection. |
| 60 | + Shards(ctx context.Context, details bool) (CollectionShards, error) |
| 61 | + |
58 | 62 | // Load the collection into memory.
|
59 | 63 | Load(ctx context.Context) error
|
60 | 64 |
|
61 |
| - // UnLoad the collection from memory. |
| 65 | + // Unload unloads the collection from memory. |
62 | 66 | Unload(ctx context.Context) error
|
63 | 67 |
|
64 | 68 | // Remove removes the entire collection.
|
@@ -262,3 +266,60 @@ type CollectionStatistics struct {
|
262 | 266 | } `json:"revisions"`
|
263 | 267 | } `json:"figures"`
|
264 | 268 | }
|
| 269 | + |
| 270 | +// CollectionShards contains shards information about a collection. |
| 271 | +type CollectionShards struct { |
| 272 | + CollectionInfo |
| 273 | + |
| 274 | + // CacheEnabled set cacheEnabled option in collection properties |
| 275 | + CacheEnabled bool `json:"cacheEnabled,omitempty"` |
| 276 | + |
| 277 | + // Set to create a smart edge or vertex collection. |
| 278 | + // This requires ArangoDB Enterprise Edition. |
| 279 | + IsSmart bool `json:"isSmart,omitempty"` |
| 280 | + |
| 281 | + KeyOptions struct { |
| 282 | + // Type specifies the type of the key generator. The currently available generators are traditional and autoincrement. |
| 283 | + Type KeyGeneratorType `json:"type,omitempty"` |
| 284 | + // AllowUserKeys; if set to true, then it is allowed to supply own key values in the _key attribute of a document. |
| 285 | + // If set to false, then the key generator is solely responsible for generating keys and supplying own key values in |
| 286 | + // the _key attribute of documents is considered an error. |
| 287 | + AllowUserKeys bool `json:"allowUserKeys,omitempty"` |
| 288 | + } `json:"keyOptions,omitempty"` |
| 289 | + |
| 290 | + // Deprecated: use 'WriteConcern' instead. |
| 291 | + MinReplicationFactor int `json:"minReplicationFactor,omitempty"` |
| 292 | + |
| 293 | + // NumberOfShards is the number of shards of the collection. |
| 294 | + // Only available in cluster setup. |
| 295 | + NumberOfShards int `json:"numberOfShards,omitempty"` |
| 296 | + |
| 297 | + // This attribute specifies the name of the sharding strategy to use for the collection. |
| 298 | + // Can not be changed after creation. |
| 299 | + ShardingStrategy ShardingStrategy `json:"shardingStrategy,omitempty"` |
| 300 | + |
| 301 | + // ShardKeys contains the names of document attributes that are used to determine the target shard for documents. |
| 302 | + // Only available in cluster setup. |
| 303 | + ShardKeys []string `json:"shardKeys,omitempty"` |
| 304 | + |
| 305 | + // Shards is a list of shards that belong to the collection. |
| 306 | + // Each shard contains a list of DB servers where the first one is the leader and the rest are followers. |
| 307 | + Shards map[ShardID][]ServerID `json:"shards,omitempty"` |
| 308 | + |
| 309 | + // StatusString represents status as a string. |
| 310 | + StatusString string `json:"statusString,omitempty"` |
| 311 | + |
| 312 | + // ReplicationFactor contains how many copies of each shard are kept on different DBServers. |
| 313 | + // Only available in cluster setup. |
| 314 | + ReplicationFactor int `json:"replicationFactor,omitempty"` |
| 315 | + |
| 316 | + // WaitForSync; If true then creating, changing or removing documents will wait |
| 317 | + // until the data has been synchronized to disk. |
| 318 | + WaitForSync bool `json:"waitForSync,omitempty"` |
| 319 | + |
| 320 | + // WriteConcern contains how many copies must be available before a collection can be written. |
| 321 | + // It is required that 1 <= WriteConcern <= ReplicationFactor. |
| 322 | + // Default is 1. Not available for satellite collections. |
| 323 | + // Available from 3.6 ArangoDB version. |
| 324 | + WriteConcern int `json:"writeConcern,omitempty"` |
| 325 | +} |
0 commit comments