@@ -33,6 +33,17 @@ type config struct {
3333 headerParams map[string]string
3434 timeouts transport.RequestConfiguration
3535
36+ {{#isIngestionClient} }
37+ // -- ChunkedPush options
38+ waitForTasks bool
39+ batchSize int
40+
41+ // -- Iterable options
42+ maxRetries int
43+ timeout func(int) time.Duration
44+ aggregator func(any, error)
45+ { {/isIngestionClient} }
46+
3647 { {#isSearchClient} }
3748 // -- ChunkedBatch options
3849 waitForTasks bool
@@ -102,42 +113,6 @@ func WithConnectTimeout(timeout time.Duration) requestOption {
102113
103114{ {#isSearchClient} }
104115
105- // --------- ChunkedBatch options ---------
106-
107- type ChunkedBatchOption interface {
108- RequestOption
109- chunkedBatch()
110- }
111-
112- type chunkedBatchOption func(*config)
113-
114- var (
115- _ ChunkedBatchOption = (*chunkedBatchOption)(nil)
116- _ ChunkedBatchOption = (*requestOption)(nil)
117- )
118-
119- func (c chunkedBatchOption) apply(conf *config) {
120- c(conf)
121- }
122-
123- func (c chunkedBatchOption) chunkedBatch() { }
124-
125- func (r requestOption) chunkedBatch() { }
126-
127- // WithWaitForTasks whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
128- func WithWaitForTasks(waitForTasks bool) chunkedBatchOption {
129- return chunkedBatchOption(func(c *config) {
130- c.waitForTasks = waitForTasks
131- } )
132- }
133-
134- // WithBatchSize the size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
135- func WithBatchSize(batchSize int) chunkedBatchOption {
136- return chunkedBatchOption(func(c *config) {
137- c.batchSize = batchSize
138- } )
139- }
140-
141116// --------- PartialUpdateObjects options ---------
142117
143118type PartialUpdateObjectsOption interface {
@@ -206,49 +181,6 @@ func WithScopes(scopes []ScopeType) replaceAllObjectsOption {
206181 } )
207182}
208183
209- // --------- Iterable options ---------.
210-
211- type IterableOption interface {
212- RequestOption
213- iterable()
214- }
215-
216- type iterableOption func(*config)
217-
218- var (
219- _ IterableOption = (*iterableOption)(nil)
220- _ IterableOption = (*requestOption)(nil)
221- )
222-
223- func (i iterableOption) apply(c *config) {
224- i(c)
225- }
226-
227- func (r requestOption) iterable() { }
228-
229- func (i iterableOption) iterable() { }
230-
231- // WithMaxRetries the maximum number of retry. Default to 50.
232- func WithMaxRetries(maxRetries int) iterableOption {
233- return iterableOption(func(c *config) {
234- c.maxRetries = maxRetries
235- } )
236- }
237-
238- // WithTimeout he function to decide how long to wait between retries. Default to min(retryCount * 200, 5000)
239- func WithTimeout(timeout func(int) time.Duration) iterableOption {
240- return iterableOption(func(c *config) {
241- c.timeout = timeout
242- } )
243- }
244-
245- // WithAggregator the function to aggregate the results of the iterable.
246- func WithAggregator(aggregator func(any, error)) iterableOption {
247- return iterableOption(func(c *config) {
248- c.aggregator = aggregator
249- } )
250- }
251-
252184// --------- WaitForKey options ---------.
253185
254186type WaitForApiKeyOption interface {
@@ -295,6 +227,18 @@ func toRequestOptions[T RequestOption](opts []T) []RequestOption {
295227 return requestOpts
296228}
297229
230+ func toIngestionRequestOptions(opts []RequestOption) []ingestion.RequestOption {
231+ requestOpts := make([]ingestion.RequestOption, 0, len(opts))
232+
233+ for _, opt := range opts {
234+ if opt, ok := opt.(ingestion.RequestOption); ok {
235+ requestOpts = append(requestOpts, opt)
236+ }
237+ }
238+
239+ return requestOpts
240+ }
241+
298242func toIterableOptions(opts []ChunkedBatchOption) []IterableOption {
299243 iterableOpts := make([]IterableOption, 0, len(opts))
300244
@@ -571,5 +515,13 @@ func (c *APIClient) {{nickname}}({{#hasParams}}r {{#structPrefix}}{{&classname}}
571515{ {/operations} }
572516
573517{ {#isSearchClient} }
518+ { {> helpers} }
519+
574520{ {> search_helpers} }
575- { {/isSearchClient} }
521+ { {/isSearchClient} }
522+
523+ { {#isIngestionClient} }
524+ { {> helpers} }
525+
526+ { {> ingestion_helpers} }
527+ { {/isIngestionClient} }
0 commit comments