MCPcopy Create free account
hub / github.com/apache/brpc / SocketOptions

Class SocketOptions

src/brpc/socket.h:249–303  ·  view source on GitHub ↗

TODO: Comment fields

Source from the content-addressed store, hash-verified

247
248// TODO: Comment fields
249struct SocketOptions {
250 // If `fd' is non-negative, set `fd' to be non-blocking and take the
251 // ownership. Socket will close the fd(if needed) and call
252 // user->BeforeRecycle() before recycling.
253 int fd{-1};
254 butil::EndPoint remote_side;
255 butil::EndPoint local_side;
256 std::string device_name;
257 // If `connect_on_create' is true and `fd' is less than 0,
258 // a client connection will be established to remote_side()
259 // regarding deadline `connect_abstime' when Socket is being created.
260 // Default: false, means that a connection will be established
261 // on first write.
262 bool connect_on_create{false};
263 // Default: NULL, means no timeout.
264 const timespec* connect_abstime{NULL};
265 SocketUser* user{NULL};
266 // When *edge-triggered* events happen on the file descriptor, callback
267 // `on_edge_triggered_events' will be called. Inside the callback, user
268 // shall read fd() in non-blocking mode until all data has been read
269 // or EAGAIN is met, otherwise the callback will not be called again
270 // until new data arrives. The callback will not be called from more than
271 // one thread at any time.
272 void (*on_edge_triggered_events)(Socket*){NULL};
273 // Indicates that this socket requires an edge-triggered event handler even
274 // if `on_edge_triggered_events` is left as NULL by the caller. When this
275 // flag is true and `on_edge_triggered_events` is NULL, the underlying
276 // transport-specific implementation (e.g. a transport subclass) is allowed
277 // to install a suitable default `on_edge_triggered_events` callback on
278 // behalf of the user. Typical usage is by transports/protocols that rely
279 // on edge-triggered I/O semantics but want the framework to provide the
280 // actual event handler.
281 bool need_on_edge_trigger{false};
282 int health_check_interval_s{-1};
283 // Only accept ssl connection.
284 bool force_ssl{false};
285 std::shared_ptr<SocketSSLContext> initial_ssl_ctx;
286 SocketMode socket_mode{SOCKET_MODE_TCP};
287 bthread_keytable_pool_t* keytable_pool{NULL};
288 SocketConnection* conn{NULL};
289 std::shared_ptr<AppConnect> app_connect;
290 // The created socket will set parsing_context with this value.
291 Destroyable* initial_parsing_context{NULL};
292
293 // Socket keepalive related options.
294 // Refer to `SocketKeepaliveOptions' for details.
295 std::shared_ptr<SocketKeepaliveOptions> keepalive_options;
296 // https://github.com/apache/brpc/issues/1154
297 // https://github.com/grpc/grpc/pull/16419/files
298 // Only linux supports TCP_USER_TIMEOUT.
299 int tcp_user_timeout_ms{ -1};
300 // Tag of this socket
301 bthread_tag_t bthread_tag{bthread_self_tag()};
302 HealthCheckOption hc_option;
303};
304
305// Abstractions on reading from and writing into file descriptors.
306// NOTE: accessed by multiple threads(frequently), align it by cacheline.

Callers 1

TEST_FFunction · 0.85

Calls 1

bthread_self_tagFunction · 0.85

Tested by 1

TEST_FFunction · 0.68