This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzerobus.h
More file actions
237 lines (200 loc) · 7.22 KB
/
Copy pathzerobus.h
File metadata and controls
237 lines (200 loc) · 7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/* Zerobus C FFI Interface */
#ifndef ZEROBUS_H
#define ZEROBUS_H
#pragma once
/* Generated with cbindgen:0.27.0 */
/* Warning: This file is autogenerated by cbindgen. Don't modify this manually. */
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
namespace zerobus {
#endif // __cplusplus
/**
* A single header key-value pair for C FFI
*/
typedef struct CHeader {
char *key;
char *value;
} CHeader;
/**
* A collection of headers returned from Go callback
*/
typedef struct CHeaders {
struct CHeader *headers;
uintptr_t count;
char *error_message;
} CHeaders;
typedef struct CZerobusSdk {
uint8_t _private[0];
} CZerobusSdk;
typedef struct CResult {
bool success;
char *error_message;
bool is_retryable;
} CResult;
typedef struct CZerobusStream {
uint8_t _private[0];
} CZerobusStream;
typedef struct CStreamConfigurationOptions {
uintptr_t max_inflight_requests;
bool recovery;
uint64_t recovery_timeout_ms;
uint64_t recovery_backoff_ms;
uint32_t recovery_retries;
uint64_t server_lack_of_ack_timeout_ms;
uint64_t flush_timeout_ms;
int32_t record_type;
uint64_t stream_paused_max_wait_time_ms;
bool has_stream_paused_max_wait_time_ms;
uint64_t callback_max_wait_time_ms;
bool has_callback_max_wait_time_ms;
} CStreamConfigurationOptions;
/**
* Function pointer type for the headers provider callback
* The callback should return a CHeaders struct
* The caller is responsible for freeing the returned CHeaders using zerobus_free_headers
*/
typedef struct CHeaders (*HeadersProviderCallback)(void *user_data);
/**
* Represents a single record (either Proto or JSON)
*/
typedef struct CRecord {
bool is_json;
uint8_t *data;
uintptr_t data_len;
} CRecord;
/**
* Represents an array of records
*/
typedef struct CRecordArray {
struct CRecord *records;
uintptr_t len;
} CRecordArray;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* Free headers returned from callback
*/
void zerobus_free_headers(struct CHeaders headers);
/**
* Create a new ZerobusSdk instance
* Returns NULL on error. Check the result parameter for error details.
*/
struct CZerobusSdk *zerobus_sdk_new(const char *zerobus_endpoint,
const char *unity_catalog_url,
struct CResult *result);
/**
* Free the SDK instance
*/
void zerobus_sdk_free(struct CZerobusSdk *sdk);
/**
* Set whether to use TLS for connections
* This should be set to false when using HTTP endpoints (e.g., for testing)
*/
void zerobus_sdk_set_use_tls(struct CZerobusSdk *sdk, bool use_tls);
/**
* Create a stream with OAuth authentication
* descriptor_proto_bytes: protobuf-encoded DescriptorProto (can be NULL for JSON streams)
*/
struct CZerobusStream *zerobus_sdk_create_stream(struct CZerobusSdk *sdk,
const char *table_name,
const uint8_t *descriptor_proto_bytes,
uintptr_t descriptor_proto_len,
const char *client_id,
const char *client_secret,
const struct CStreamConfigurationOptions *options,
struct CResult *result);
/**
* Create a stream with a custom headers provider callback
* This allows you to provide custom authentication headers via a Go callback function
*/
struct CZerobusStream *zerobus_sdk_create_stream_with_headers_provider(struct CZerobusSdk *sdk,
const char *table_name,
const uint8_t *descriptor_proto_bytes,
uintptr_t descriptor_proto_len,
HeadersProviderCallback headers_callback,
void *user_data,
const struct CStreamConfigurationOptions *options,
struct CResult *result);
/**
* Free a stream instance
*/
void zerobus_stream_free(struct CZerobusStream *stream);
/**
* Ingest a record (protobuf encoded)
* Returns the offset directly
* Returns -1 on error
*/
int64_t zerobus_stream_ingest_proto_record(struct CZerobusStream *stream,
const uint8_t *data,
uintptr_t data_len,
struct CResult *result);
/**
* Ingest a JSON record
* Returns the offset directly
* Returns -1 on error
*/
int64_t zerobus_stream_ingest_json_record(struct CZerobusStream *stream,
const char *json_data,
struct CResult *result);
/**
* Ingest a batch of protobuf records
* Returns the offset of the last record in the batch, or -1 on error
* Returns -2 if batch is empty
*/
int64_t zerobus_stream_ingest_proto_records(struct CZerobusStream *stream,
const uint8_t *const *records,
const uintptr_t *record_lens,
uintptr_t num_records,
struct CResult *result);
/**
* Ingest a batch of JSON records
* Returns the offset of the last record in the batch, or -1 on error
* Returns -2 if batch is empty
*/
int64_t zerobus_stream_ingest_json_records(struct CZerobusStream *stream,
const char *const *json_records,
uintptr_t num_records,
struct CResult *result);
/**
* Wait for a specific offset to be acknowledged by the server
*/
bool zerobus_stream_wait_for_offset(struct CZerobusStream *stream,
int64_t offset,
struct CResult *result);
/**
* Flush all pending records
*/
bool zerobus_stream_flush(struct CZerobusStream *stream, struct CResult *result);
/**
* Get unacknowledged records from a closed stream
* Returns a CRecordArray that must be freed with zerobus_free_record_array
*/
struct CRecordArray zerobus_stream_get_unacked_records(struct CZerobusStream *stream,
struct CResult *result);
/**
* Free a CRecordArray returned by zerobus_stream_get_unacked_records
*/
void zerobus_free_record_array(struct CRecordArray array);
/**
* Close the stream gracefully
*/
bool zerobus_stream_close(struct CZerobusStream *stream, struct CResult *result);
/**
* Free error message string
*/
void zerobus_free_error_message(char *message);
/**
* Get default configuration options
*/
struct CStreamConfigurationOptions zerobus_get_default_config(void);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#ifdef __cplusplus
} // namespace zerobus
#endif // __cplusplus
#endif /* ZEROBUS_H */