pub struct ServiceModel {
pub api_key_prefix: String,
pub owners: Vec<ServiceOwnerModel>,
pub upstream_url: String,
pub tls_profile: Option<TlsProfile>,
}Expand description
Represents a service model stored in the database.
Fields§
§api_key_prefix: StringThe service API Key prefix.
owners: Vec<ServiceOwnerModel>A List of service owners.
upstream_url: StringThe service upstream URL.
This what the proxy will use to forward requests to the service.
tls_profile: Option<TlsProfile>TLS profile configuration for this service
Implementations§
Source§impl ServiceModel
impl ServiceModel
Sourcepub fn new(
api_key_prefix: impl Into<String>,
upstream_url: impl Into<String>,
) -> Self
pub fn new( api_key_prefix: impl Into<String>, upstream_url: impl Into<String>, ) -> Self
Convenience constructor to reduce boilerplate in tests.
Sourcepub fn find_by_id(id: ServiceId, db: &RocksDb) -> Result<Option<Self>, Error>
pub fn find_by_id(id: ServiceId, db: &RocksDb) -> Result<Option<Self>, Error>
Find a service by its ID in the database.
Sourcepub fn save(&self, id: ServiceId, db: &RocksDb) -> Result<(), Error>
pub fn save(&self, id: ServiceId, db: &RocksDb) -> Result<(), Error>
Saves the service to the database at the given ID.
Sourcepub fn delete(id: ServiceId, db: &RocksDb) -> Result<(), Error>
pub fn delete(id: ServiceId, db: &RocksDb) -> Result<(), Error>
Deletes the service from the database.
pub fn api_key_prefix(&self) -> &str
Sourcepub fn is_owner(&self, key_type: KeyType, key_bytes: &[u8]) -> bool
pub fn is_owner(&self, key_type: KeyType, key_bytes: &[u8]) -> bool
Checks if the service has a specific owner.
Sourcepub fn add_owner(&mut self, key_type: KeyType, key_bytes: Vec<u8>)
pub fn add_owner(&mut self, key_type: KeyType, key_bytes: Vec<u8>)
Adds a new owner to the service.
Sourcepub fn remove_owner(&mut self, key_type: KeyType, key_bytes: &[u8])
pub fn remove_owner(&mut self, key_type: KeyType, key_bytes: &[u8])
Removes an owner from the service.
Sourcepub fn owners(&self) -> &[ServiceOwnerModel]
pub fn owners(&self) -> &[ServiceOwnerModel]
Returns the list of owners.
Sourcepub fn upstream_url(&self) -> Result<Uri, Error>
pub fn upstream_url(&self) -> Result<Uri, Error>
Returns the upstream URL.
Sourcepub fn tls_profile(&self) -> Option<&TlsProfile>
pub fn tls_profile(&self) -> Option<&TlsProfile>
Get the TLS profile for this service
Sourcepub fn set_tls_profile(&mut self, tls_profile: TlsProfile)
pub fn set_tls_profile(&mut self, tls_profile: TlsProfile)
Set the TLS profile for this service
Sourcepub fn is_tls_enabled(&self) -> bool
pub fn is_tls_enabled(&self) -> bool
Check if TLS is enabled for this service
Sourcepub fn requires_client_mtls(&self) -> bool
pub fn requires_client_mtls(&self) -> bool
Check if client mTLS is required for this service
Trait Implementations§
Source§impl Clone for ServiceModel
impl Clone for ServiceModel
Source§fn clone(&self) -> ServiceModel
fn clone(&self) -> ServiceModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServiceModel
impl Debug for ServiceModel
Source§impl Default for ServiceModel
impl Default for ServiceModel
Source§impl Message for ServiceModel
impl Message for ServiceModel
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.Auto Trait Implementations§
impl Freeze for ServiceModel
impl RefUnwindSafe for ServiceModel
impl Send for ServiceModel
impl Sync for ServiceModel
impl Unpin for ServiceModel
impl UnwindSafe for ServiceModel
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more