Struct ngrok::session::SessionBuilder
source · pub struct SessionBuilder { /* private fields */ }
Expand description
The builder for an ngrok Session.
Implementations§
source§impl SessionBuilder
impl SessionBuilder
sourcepub fn authtoken(self, authtoken: impl Into<String>) -> Self
pub fn authtoken(self, authtoken: impl Into<String>) -> Self
Configures the session to authenticate with the provided authtoken. You can find your existing authtoken or create a new one in the ngrok dashboard.
See the authtoken parameter in the ngrok docs for additional details.
sourcepub fn authtoken_from_env(self) -> Self
pub fn authtoken_from_env(self) -> Self
Shortcut for calling SessionBuilder::authtoken with the value of the NGROK_AUTHTOKEN environment variable.
sourcepub fn heartbeat_interval(self, heartbeat_interval: Duration) -> Self
pub fn heartbeat_interval(self, heartbeat_interval: Duration) -> Self
Configures how often the session will send heartbeat messages to the ngrok service to check session liveness.
See the heartbeat_interval parameter in the ngrok docs for additional details.
sourcepub fn heartbeat_tolerance(self, heartbeat_tolerance: Duration) -> Self
pub fn heartbeat_tolerance(self, heartbeat_tolerance: Duration) -> Self
Configures the duration to wait for a response to a heartbeat before assuming the session connection is dead and attempting to reconnect.
See the heartbeat_tolerance parameter in the ngrok docs for additional details.
sourcepub fn metadata(self, metadata: impl Into<String>) -> Self
pub fn metadata(self, metadata: impl Into<String>) -> Self
Configures the opaque, machine-readable metadata string for this session. Metadata is made available to you in the ngrok dashboard and the Agents API resource. It is a useful way to allow you to uniquely identify sessions. We suggest encoding the value in a structured format like JSON.
See the metdata parameter in the ngrok docs for additional details.
sourcepub fn server_addr(self, addr: impl Into<String>) -> Self
pub fn server_addr(self, addr: impl Into<String>) -> Self
Configures the network address to dial to connect to the ngrok service. Use this option only if you are connecting to a custom agent ingress.
See the server_addr parameter in the ngrok docs for additional details.
sourcepub fn tls_config(self, config: ClientConfig) -> Self
pub fn tls_config(self, config: ClientConfig) -> Self
Configures the TLS client used to connect to the ngrok service while
establishing the session. Use this option only if you are connecting through
a man-in-the-middle or deep packet inspection proxy. Passed to the
connect callback set with SessionBuilder::connect
.
Roughly corresponds to the root_cas parameter in the ngrok docs, but allows for deeper TLS configuration.
sourcepub fn connector(self, connect: impl Connector) -> Self
pub fn connector(self, connect: impl Connector) -> Self
Configures a function which is called to establish the connection to the ngrok service. Use this option if you need to connect through an outbound proxy. In the event of network disruptions, it will be called each time the session reconnects.
sourcepub fn handle_stop_command(self, handler: impl CommandHandler<Stop>) -> Self
pub fn handle_stop_command(self, handler: impl CommandHandler<Stop>) -> Self
Configures a function which is called when the ngrok service requests that this Session stops. Your application may choose to interpret this callback as a request to terminate the Session or the entire process.
Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Stop operation.
Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call std::process::exit inside this callback, it will also cause the operation to time out.
sourcepub fn handle_restart_command(
self,
handler: impl CommandHandler<Restart>
) -> Self
pub fn handle_restart_command( self, handler: impl CommandHandler<Restart> ) -> Self
Configures a function which is called when the ngrok service requests that this Session updates. Your application may choose to interpret this callback as a request to restart the Session or the entire process.
Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Restart operation.
Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call std::process::exit inside this callback, it will also cause the operation to time out.
sourcepub fn handle_update_command(self, handler: impl CommandHandler<Update>) -> Self
pub fn handle_update_command(self, handler: impl CommandHandler<Update>) -> Self
Configures a function which is called when the ngrok service requests that this Session updates. Your application may choose to interpret this callback as a request to update its configuration, itself, or to invoke some other application-specific behavior.
Errors returned by this function will be visible to the ngrok dashboard or API as the response to the Restart operation.
Do not block inside this callback. It will cause the Dashboard or API stop operation to time out. Do not call std::process::exit inside this callback, it will also cause the operation to time out.
sourcepub fn handle_heartbeat(self, callback: impl HeartbeatHandler) -> Self
pub fn handle_heartbeat(self, callback: impl HeartbeatHandler) -> Self
Call the provided handler whenever a heartbeat response is received.
If the handler returns an error, the heartbeat task will exit, resulting in the session eventually dying as well.
Trait Implementations§
source§impl Clone for SessionBuilder
impl Clone for SessionBuilder
source§fn clone(&self) -> SessionBuilder
fn clone(&self) -> SessionBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more