- Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathproxy_wasm_externs.h
200 lines (179 loc) · 11.4 KB
/
proxy_wasm_externs.h
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
/*
* Copyright 2016-2019 Envoy Project Authors
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Proxy-WASM ABI.
*/
// NOLINT(namespace-envoy)
#pragma once
#include<stddef.h>
#include<stdint.h>
#include"proxy_wasm_common.h"
#include"proxy_wasm_enums.h"
//
// ABI
//
// Configuration and Status
extern"C"WasmResultproxy_get_configuration(constchar**configuration_ptr,
size_t*configuration_size);
// Results status details for any previous ABI call and onGrpcClose.
extern"C"WasmResultproxy_get_status(uint32_t*status_code_ptr, constchar**message_ptr,
size_t*message_size);
// Logging
extern"C"WasmResultproxy_log(LogLevellevel, constchar*logMessage, size_tmessageSize);
extern"C"WasmResultproxy_get_log_level(LogLevel*level);
// Timer (will be set for the root context, e.g. onStart, onTick).
extern"C"WasmResultproxy_set_tick_period_milliseconds(uint32_tmillisecond);
// Time
extern"C"WasmResultproxy_get_current_time_nanoseconds(uint64_t*nanoseconds);
// State accessors
extern"C"WasmResultproxy_get_property(constchar*path_ptr, size_tpath_size,
constchar**value_ptr_ptr, size_t*value_size_ptr);
extern"C"WasmResultproxy_set_property(constchar*path_ptr, size_tpath_size,
constchar*value_ptr, size_tvalue_size);
// Continue/Close/Reply/Route
extern"C"WasmResultproxy_continue_stream(WasmStreamTypestream_type);
extern"C"WasmResultproxy_close_stream(WasmStreamTypestream_type);
extern"C"WasmResult
proxy_send_local_response(uint32_tresponse_code, constchar*response_code_details_ptr,
size_tresponse_code_details_size, constchar*body_ptr, size_tbody_size,
constchar*additional_response_header_pairs_ptr,
size_tadditional_response_header_pairs_size, uint32_tgrpc_status);
extern"C"WasmResultproxy_clear_route_cache();
// SharedData
// Returns: Ok, NotFound
extern"C"WasmResultproxy_get_shared_data(constchar*key_ptr, size_tkey_size,
constchar**value_ptr, size_t*value_size,
uint32_t*cas);
// If cas != 0 and cas != the current cas for 'key' return false, otherwise set
// the value and return true.
// Returns: Ok, CasMismatch
extern"C"WasmResultproxy_set_shared_data(constchar*key_ptr, size_tkey_size,
constchar*value_ptr, size_tvalue_size, uint32_tcas);
// SharedQueue
// Note: Registering the same queue_name will overwrite the old registration
// while preseving any pending data. Consequently it should typically be
// followed by a call to proxy_dequeue_shared_queue. Returns: Ok
extern"C"WasmResultproxy_register_shared_queue(constchar*queue_name_ptr,
size_tqueue_name_size, uint32_t*token);
// Returns: Ok, NotFound
extern"C"WasmResultproxy_resolve_shared_queue(constchar*vm_id, size_tvm_id_size,
constchar*queue_name_ptr, size_tqueue_name_size,
uint32_t*token);
// Returns Ok, Empty, NotFound (token not registered).
extern"C"WasmResultproxy_dequeue_shared_queue(uint32_ttoken, constchar**data_ptr,
size_t*data_size);
// Returns false if the queue was not found and the data was not enqueued.
extern"C"WasmResultproxy_enqueue_shared_queue(uint32_ttoken, constchar*data_ptr,
size_tdata_size);
// Headers/Trailers/Metadata Maps
extern"C"WasmResultproxy_add_header_map_value(WasmHeaderMapTypetype, constchar*key_ptr,
size_tkey_size, constchar*value_ptr,
size_tvalue_size);
extern"C"WasmResultproxy_get_header_map_value(WasmHeaderMapTypetype, constchar*key_ptr,
size_tkey_size, constchar**value_ptr,
size_t*value_size);
extern"C"WasmResultproxy_get_header_map_pairs(WasmHeaderMapTypetype, constchar**ptr,
size_t*size);
extern"C"WasmResultproxy_set_header_map_pairs(WasmHeaderMapTypetype, constchar*ptr,
size_tsize);
extern"C"WasmResultproxy_replace_header_map_value(WasmHeaderMapTypetype, constchar*key_ptr,
size_tkey_size, constchar*value_ptr,
size_tvalue_size);
extern"C"WasmResultproxy_remove_header_map_value(WasmHeaderMapTypetype, constchar*key_ptr,
size_tkey_size);
extern"C"WasmResultproxy_get_header_map_size(WasmHeaderMapTypetype, size_t*size);
// Buffer
extern"C"WasmResultproxy_get_buffer_bytes(WasmBufferTypetype, uint32_tstart, uint32_tlength,
constchar**ptr, size_t*size);
extern"C"WasmResultproxy_get_buffer_status(WasmBufferTypetype, size_t*length_ptr,
uint32_t*flags_ptr);
extern"C"WasmResultproxy_set_buffer_bytes(WasmBufferTypetype, uint32_tstart, uint32_tlength,
constchar*ptr, size_tsize);
// HTTP
extern"C"WasmResultproxy_http_call(constchar*uri_ptr, size_turi_size, void*header_pairs_ptr,
size_theader_pairs_size, constchar*body_ptr,
size_tbody_size, void*trailer_pairs_ptr,
size_ttrailer_pairs_size, uint32_ttimeout_milliseconds,
uint32_t*token_ptr);
// gRPC
extern"C"WasmResultproxy_grpc_call(constchar*service_ptr, size_tservice_size,
constchar*service_name_ptr, size_tservice_name_size,
constchar*method_name_ptr, size_tmethod_name_size,
void*initial_metadata_ptr, size_tinitial_metadata_size,
constchar*request_ptr, size_trequest_size,
uint32_ttimeout_milliseconds, uint32_t*token_ptr);
extern"C"WasmResultproxy_grpc_stream(constchar*service_ptr, size_tservice_size,
constchar*service_name_ptr, size_tservice_name_size,
constchar*method_name_ptr, size_tmethod_name_size,
void*initial_metadata, size_tinitial_metadata_size,
uint32_t*token_ptr);
extern"C"WasmResultproxy_grpc_cancel(uint32_ttoken);
extern"C"WasmResultproxy_grpc_close(uint32_ttoken);
extern"C"WasmResultproxy_grpc_send(uint32_ttoken, constchar*message_ptr, size_tmessage_size,
uint32_tend_stream);
// Metrics
extern"C"WasmResultproxy_define_metric(MetricTypetype, constchar*name_ptr, size_tname_size,
uint32_t*metric_id);
extern"C"WasmResultproxy_increment_metric(uint32_tmetric_id, int64_toffset);
extern"C"WasmResultproxy_record_metric(uint32_tmetric_id, uint64_tvalue);
extern"C"WasmResultproxy_get_metric(uint32_tmetric_id, uint64_t*result);
// System
extern"C"WasmResultproxy_set_effective_context(uint32_teffective_context_id);
extern"C"WasmResultproxy_done();
extern"C"WasmResultproxy_call_foreign_function(constchar*function_name,
size_tfunction_name_size, constchar*arguments,
size_targuments_size, char**results,
size_t*results_size);
// Calls in.
extern"C"uint32_tproxy_on_vm_start(uint32_troot_context_id, uint32_tconfiguration_size);
extern"C"uint32_tproxy_validate_configuration(uint32_troot_context_id,
uint32_tconfiguration_size);
extern"C"uint32_tproxy_on_configure(uint32_troot_context_id, uint32_tconfiguration_size);
extern"C"voidproxy_on_tick(uint32_troot_context_id);
extern"C"voidproxy_on_foreign_function(uint32_troot_context_id, uint32_tfunction_id,
uint32_tdata_size);
extern"C"voidproxy_on_queue_ready(uint32_troot_context_id, uint32_ttoken);
// Stream calls.
extern"C"voidproxy_on_context_create(uint32_tcontext_id, uint32_tparent_context_id);
extern"C"FilterHeadersStatusproxy_on_request_headers(uint32_tcontext_id, uint32_theaders,
uint32_tend_of_stream);
extern"C"FilterDataStatusproxy_on_request_body(uint32_tcontext_id, uint32_tbody_buffer_length,
uint32_tend_of_stream);
extern"C"FilterTrailersStatusproxy_on_request_trailers(uint32_tcontext_id, uint32_ttrailers);
extern"C"FilterMetadataStatusproxy_on_request_metadata(uint32_tcontext_id, uint32_tnelements);
extern"C"FilterHeadersStatusproxy_on_response_headers(uint32_tcontext_id, uint32_theaders,
uint32_tend_of_stream);
extern"C"FilterDataStatusproxy_on_response_body(uint32_tcontext_id, uint32_tbody_buffer_length,
uint32_tend_of_stream);
extern"C"FilterTrailersStatusproxy_on_response_trailers(uint32_tcontext_id, uint32_ttrailers);
extern"C"FilterMetadataStatusproxy_on_response_metadata(uint32_tcontext_id, uint32_tnelements);
// HTTP/gRPC.
extern"C"voidproxy_on_http_call_response(uint32_tcontext_id, uint32_ttoken, uint32_theaders,
uint32_tbody_size, uint32_ttrailers);
extern"C"voidproxy_on_grpc_receive_initial_metadata(uint32_tcontext_id, uint32_ttoken,
uint32_theaders);
extern"C"voidproxy_on_grpc_trailing_metadata(uint32_tcontext_id, uint32_ttoken,
uint32_ttrailers);
extern"C"voidproxy_on_grpc_receive(uint32_tcontext_id, uint32_ttoken, uint32_tresponse_size);
extern"C"voidproxy_on_grpc_close(uint32_tcontext_id, uint32_ttoken, uint32_tstatus_code);
// The stream/vm has completed.
extern"C"uint32_tproxy_on_done(uint32_tcontext_id);
// proxy_on_log occurs after proxy_on_done.
extern"C"voidproxy_on_log(uint32_tcontext_id);
// The Context in the proxy has been destroyed and no further calls will be
// coming.
extern"C"voidproxy_on_delete(uint32_tcontext_id);