Expand description
Client SDK for a deployed pb-mapper relay.
ⓘ
use std::time::Duration;
use pb_mapper::{Client, ClientConfig, ConnectRequest, RegisterRequest, Transport};
let client = Client::new(ClientConfig {
server: "relay.example.com:7666".into(),
credential: std::env::var("MSG_HEADER_KEY").expect("MSG_HEADER_KEY"),
keep_alive: true,
namespace: None,
})?;
let registration = client
.register(RegisterRequest {
key: "echo".into(),
local_addr: "127.0.0.1:8080".into(),
transport: Transport::Tcp,
codec: false,
force_namespace: false,
})
.await?;
registration.wait_ready().await?;
let _keys = client.list_keys().await?;
let issued = client
.admin()?
.issue_key(Duration::from_secs(3600), Some("agent".into()))
.await?;
client.admin()?.revoke_key(issued.key_id).await?;
registration.stop().await?;The CLI binary still lives in pb-mapper-cli. That crate is publish = false, so build it from a checkout — make build-pb-mapper, or cargo build --release --bin pb-mapper — rather than installing it from a registry.
Structs§
- Admin
- Administrator RPCs. Constructed via
super::Client::admin. - Auth
Status Info - Relay-side snapshot of the credential subsystem.
- Client
- Session against one deployed relay.
- Client
Config - Configuration for a
Clientsession. - Connect
Request - Subscribe to a registered service and listen locally.
- Connection
- A live
connecttunnel: a local listener forwarding to a registered service. - Connection
Info - One control connection the relay holds for a registered service.
- Connection
Page - One page of live service connections.
- Issued
Key - A temporary credential, with the secret the relay just minted.
- KeyList
Page - One page of temporary credentials.
- KeyMetadata
- A temporary credential without its secret.
- Register
Request - Register a local TCP/UDP service with the relay.
- Registration
- A live
registertunnel: a local service published on the relay. - Remote
Id - Relay mapping dump from
status remote-id. - Service
Connection - One control connection the relay is holding for a service key.
- Service
Info - A registered service as the relay sees it.
- Service
Page - One page of registered services.
- Tunnel
Diagnostics - A point-in-time view of this tunnel and its process-shared relay budget.
Enums§
- Error
- Errors returned by the client SDK.
- Legacy
Protocol - Legacy framing policy, matching
pb-mapper admin legacy-protocol. - Recovery
Failure - Why a recovery attempt failed, without credentials or application data.
- Recovery
Phase - The phase most recently entered by a tunnel worker.
- Transport
- Transport used by a registered service or a local subscriber.
- Tunnel
Status - Observed lifecycle of a
super::Registrationorsuper::Connection.
Constants§
- SDK_
VERSION - The SDK version compiled into this process.