@@ -7,32 +7,56 @@ import (
7
7
// GraphAPI represent the graph API from a data source point of view
8
8
type GraphAPI struct {
9
9
client * GraphClient
10
+
11
+ parallelization int
12
+ chunkSize int
10
13
}
11
14
12
15
// GraphAPIOptions options to pass to build graph API
13
16
type GraphAPIOptions struct {
14
- URL string
15
- AuthToken string
17
+ // URL to GraphKB
18
+ URL string
19
+ // Auth token for this data source.
20
+ AuthToken string
21
+ // Skip verifying the certificate when using https
16
22
SkipVerify bool
23
+
24
+ // The level of parallelization for streaming updates, i.e., number of HTTP requests sent in parallel.
25
+ Parallelization int
26
+
27
+ // The size of a chunk of updates, i.e., number of assets or relations sent in one HTTP request to the streaming API.
28
+ ChunkSize int
17
29
}
18
30
19
31
// NewGraphAPI create an emitter of graph
20
32
func NewGraphAPI (options GraphAPIOptions ) * GraphAPI {
21
33
return & GraphAPI {
22
- client : NewGraphClient (options .URL , options .AuthToken , options .SkipVerify ),
34
+ client : NewGraphClient (options .URL , options .AuthToken , options .SkipVerify ),
35
+ parallelization : options .Parallelization ,
36
+ chunkSize : options .ChunkSize ,
23
37
}
24
38
}
25
39
26
40
// CreateTransaction create a full graph transaction. This kind of transaction will diff the new graph
27
41
// with previous version of it.
28
42
func (gapi * GraphAPI ) CreateTransaction (currentGraph * knowledge.Graph ) * Transaction {
43
+ var parallelization = gapi .parallelization
44
+ if parallelization == 0 {
45
+ parallelization = 30
46
+ }
47
+
48
+ var chunkSize = gapi .chunkSize
49
+ if chunkSize == 0 {
50
+ chunkSize = 1000
51
+ }
52
+
29
53
transaction := new (Transaction )
30
54
transaction .newGraph = knowledge .NewGraph ()
31
55
transaction .binder = knowledge .NewGraphBinder (transaction .newGraph )
32
56
transaction .client = gapi .client
33
57
transaction .currentGraph = currentGraph
34
- transaction .parallelization = 30
35
- transaction .chunkSize = 1000
58
+ transaction .parallelization = parallelization
59
+ transaction .chunkSize = chunkSize
36
60
return transaction
37
61
}
38
62
0 commit comments