Files
el/ui/vessels/el-services/src/lib.rs
T

52 lines
1.3 KiB
Rust

//! el-services — Service bindings for el-ui.
//!
//! Write once. Bind to any protocol. Change the binding in `el.toml`.
//!
//! ```toml
//! [services.UserService]
//! binding = "rest"
//! base_url = "https://api.example.com"
//! auth = "bearer"
//! ```
//!
//! Switch `binding = "grpc"` and the same service code now speaks gRPC. No rewrite.
pub mod binding;
pub mod config;
pub mod proxy;
pub mod registry;
pub use binding::{
direct::DirectBinding,
grpc::GrpcBinding,
rest::RestBinding,
websocket::WebSocketBinding,
Binding, BindingKind, ServiceRequest, ServiceResponse,
};
pub use config::{AuthConfig, ServiceConfig};
pub use proxy::{ServiceMethod, ServiceProxy};
pub use registry::ServiceRegistry;
#[cfg(test)]
mod tests;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ServiceError {
#[error("service not found: {0}")]
NotFound(String),
#[error("binding error: {0}")]
Binding(String),
#[error("serialization error: {0}")]
Serialization(String),
#[error("transport error: {0}")]
Transport(String),
#[error("auth error: {0}")]
Auth(String),
#[error("method not found: {method} on service {service}")]
MethodNotFound { service: String, method: String },
}
pub type ServiceResult<T> = Result<T, ServiceError>;