Fastly Compute C++ SDK
Loading...
Searching...
No Matches
backend.h
Go to the documentation of this file.
1#ifndef FASTLY_BACKEND_H
2#define FASTLY_BACKEND_H
3
4#include <chrono>
5#include <fastly/error.h>
7#include <fastly/sdk-sys.h>
8#include <string>
9#include <string_view>
10
11#include <iostream>
12
13namespace fastly::http {
14class Request;
15class Response;
16} // namespace fastly::http
17
18namespace fastly::backend {
19
20class BackendBuilder;
21class Backend {
24 friend BackendBuilder;
25
26public:
27 static fastly::expected<Backend> from_name(std::string_view name);
28 Backend clone();
29 BackendBuilder builder(std::string_view name, std::string_view target);
30 std::string name();
31 std::string into_string();
32 bool exists();
33 bool is_dynamic();
34 std::string get_host();
35 // TODO(@zkat): Do something about the optional thing here.
36 // std::string get_host_override();
37 uint16_t get_port();
38 std::chrono::milliseconds get_connect_timeout();
39 std::chrono::milliseconds get_first_byte_timeout();
40 std::chrono::milliseconds get_between_byte_timeout();
41 std::chrono::milliseconds get_http_keepalive_time();
43 std::chrono::milliseconds get_tcp_keepalive_interval();
45 std::chrono::milliseconds get_tcp_keepalive_time();
46 bool is_ssl();
47 bool operator==(Backend b) { return backend->equals(*b.backend); }
48 bool operator!=(Backend b) { return !backend->equals(*b.backend); }
49 // TODO(@zkat): optional stuff is weird.
50 // SslVersion get_ssl_min_version();
51 // SslVersion get_ssl_max_version();
52private:
53 Backend(rust::Box<fastly::sys::backend::Backend> b)
54 : backend(std::move(b)) {};
55 rust::Box<fastly::sys::backend::Backend> backend;
56};
57
59 friend Backend;
60
61public:
62 BackendBuilder(std::string_view name, std::string_view target)
63 : builder(fastly::sys::backend::m_static_backend_backend_builder_new(
64 static_cast<std::string>(name), static_cast<std::string>(target))) {
65 };
66 BackendBuilder override_host(std::string_view name) &&;
67 BackendBuilder connect_timeout(std::chrono::milliseconds timeout) &&;
68 BackendBuilder first_byte_timeout(std::chrono::milliseconds timeout) &&;
69 BackendBuilder between_bytes_timeout(std::chrono::milliseconds timeout) &&;
72 BackendBuilder check_certificate(std::string_view cert) &&;
73 BackendBuilder ca_certificate(std::string_view cert) &&;
74 BackendBuilder tls_ciphers(std::string_view ciphers) &&;
75 BackendBuilder sni_hostname(std::string_view host) &&;
77 BackendBuilder http_keepalive_time(std::chrono::milliseconds timeout) &&;
83
84private:
85 BackendBuilder(rust::Box<fastly::sys::backend::BackendBuilder> b)
86 : builder(std::move(b)) {};
87 rust::Box<fastly::sys::backend::BackendBuilder> builder;
88};
89
90} // namespace fastly::backend
91
92#endif
Definition backend.h:58
BackendBuilder tcp_keepalive_interval_secs(uint32_t secs) &&
BackendBuilder between_bytes_timeout(std::chrono::milliseconds timeout) &&
BackendBuilder http_keepalive_time(std::chrono::milliseconds timeout) &&
BackendBuilder ca_certificate(std::string_view cert) &&
BackendBuilder enable_pooling(bool enable) &&
BackendBuilder enable_ssl() &&
BackendBuilder disable_ssl() &&
BackendBuilder(std::string_view name, std::string_view target)
Definition backend.h:62
fastly::expected< Backend > finish() &&
BackendBuilder connect_timeout(std::chrono::milliseconds timeout) &&
BackendBuilder sni_hostname(std::string_view host) &&
BackendBuilder override_host(std::string_view name) &&
BackendBuilder tls_ciphers(std::string_view ciphers) &&
BackendBuilder check_certificate(std::string_view cert) &&
BackendBuilder tcp_keepalive_enable(bool enable) &&
BackendBuilder tcp_keepalive_probes(uint32_t probes) &&
BackendBuilder tcp_keepalive_time_secs(uint32_t secs) &&
BackendBuilder first_byte_timeout(std::chrono::milliseconds timeout) &&
Definition backend.h:21
std::chrono::milliseconds get_first_byte_timeout()
std::chrono::milliseconds get_connect_timeout()
std::chrono::milliseconds get_between_byte_timeout()
bool operator!=(Backend b)
Definition backend.h:48
uint32_t get_tcp_keepalive_probes()
BackendBuilder builder(std::string_view name, std::string_view target)
std::chrono::milliseconds get_http_keepalive_time()
std::chrono::milliseconds get_tcp_keepalive_interval()
std::chrono::milliseconds get_tcp_keepalive_time()
bool operator==(Backend b)
Definition backend.h:47
static fastly::expected< Backend > from_name(std::string_view name)
std::string into_string()
Definition request.h:149
Definition response.h:94
Definition backend.h:18
tl::expected< T, FastlyError > expected
Definition error.h:25
Definition backend.h:13
Definition backend.h:13