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
20using fastly::sys::backend::SslVersion;
21
22class BackendBuilder;
23class Backend {
26 friend BackendBuilder;
27
28public:
29 static fastly::expected<Backend> from_name(std::string_view name);
30 Backend clone();
31 BackendBuilder builder(std::string_view name, std::string_view target);
32 std::string name();
33 std::string into_string();
34 bool exists();
35 bool is_dynamic();
36 std::string get_host();
37 // TODO(@zkat): Do something about the optional thing here.
38 // std::string get_host_override();
39 uint16_t get_port();
40 std::chrono::milliseconds get_connect_timeout();
41 std::chrono::milliseconds get_first_byte_timeout();
42 std::chrono::milliseconds get_between_byte_timeout();
43 std::chrono::milliseconds get_http_keepalive_time();
45 std::chrono::milliseconds get_tcp_keepalive_interval();
47 std::chrono::milliseconds get_tcp_keepalive_time();
48 bool is_ssl();
49 bool operator==(Backend b) { return backend->equals(*b.backend); }
50 bool operator!=(Backend b) { return !backend->equals(*b.backend); }
51 // TODO(@zkat): optional stuff is weird.
52 // SslVersion get_ssl_min_version();
53 // SslVersion get_ssl_max_version();
54private:
55 Backend(rust::Box<fastly::sys::backend::Backend> b)
56 : backend(std::move(b)) {};
57 rust::Box<fastly::sys::backend::Backend> backend;
58};
59
61 friend Backend;
62
63public:
64 BackendBuilder(std::string_view name, std::string_view target)
65 : builder(fastly::sys::backend::m_static_backend_backend_builder_new(
66 static_cast<std::string>(name), static_cast<std::string>(target))) {
67 };
68 BackendBuilder override_host(std::string_view name) &&;
69 BackendBuilder connect_timeout(std::chrono::milliseconds timeout) &&;
70 BackendBuilder first_byte_timeout(std::chrono::milliseconds timeout) &&;
71 BackendBuilder between_bytes_timeout(std::chrono::milliseconds timeout) &&;
74 BackendBuilder set_min_tls_version(SslVersion version) &&;
75 BackendBuilder set_max_tls_version(SslVersion version) &&;
76 BackendBuilder check_certificate(std::string_view cert) &&;
77 BackendBuilder ca_certificate(std::string_view cert) &&;
78 BackendBuilder tls_ciphers(std::string_view ciphers) &&;
79 BackendBuilder sni_hostname(std::string_view host) &&;
81 BackendBuilder http_keepalive_time(std::chrono::milliseconds timeout) &&;
87
88private:
89 BackendBuilder(rust::Box<fastly::sys::backend::BackendBuilder> b)
90 : builder(std::move(b)) {};
91 rust::Box<fastly::sys::backend::BackendBuilder> builder;
92};
93
94} // namespace fastly::backend
95
96#endif
Definition backend.h:60
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 set_max_tls_version(SslVersion version) &&
BackendBuilder enable_ssl() &&
BackendBuilder disable_ssl() &&
BackendBuilder set_min_tls_version(SslVersion version) &&
BackendBuilder(std::string_view name, std::string_view target)
Definition backend.h:64
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:23
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:50
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:49
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