Skip to content
Snippets Groups Projects
Select Git revision
  • 0475385a5fb896ed146711687d588e239dc4a7ee
  • master default protected
  • kirovets_doc
  • ypodlesov/unite-projection
  • max/parse-anonymous-blocks
  • sd/constant
  • docs/server_setup
  • ekhamitov/union-types
  • docs/privileges
  • sd/2244-issue
  • raiondesu/1984-used-tier-memory
  • lomakin/adr-client-bucket-awareness
  • lomakin/insert-query-sharding-metadata
  • 25.4 protected
  • ekhamitov/1977-remove-additional-child
  • gmoshkin/box-error-improvements
  • astrochuk/explain-fix
  • dkoltsov/support-https
  • docs/config_storage
  • ekhamitov/2365-fix-flaky
  • kostja-check-quorum
  • 25.4.4 protected
  • 25.3.8 protected
  • 25.3.7 protected
  • 25.4.3 protected
  • 25.3.6 protected
  • 25.4.2 protected
  • 25.3.5 protected
  • 25.4.1 protected
  • 25.5.0 protected
  • 25.3.4 protected
  • 25.3.3 protected
  • 25.3.2 protected
  • 25.4.0 protected
  • 25.3.1 protected
  • 25.2.4 protected
  • 25.2.3 protected
  • 25.2.2 protected
  • 25.2.1 protected
  • 25.3.0 protected
  • 25.1.2 protected
41 results

replicaset.rs

Blame
  • replicaset.rs 5.22 KiB
    use super::instance::InstanceId;
    use crate::instance::Instance;
    use ::tarantool::tlua;
    use ::tarantool::tuple::Encode;
    
    // TODO: this redundant boilerplate needs to be removed
    crate::define_string_newtype! {
        /// Unique id of a replicaset.
        ///
        /// This is a new-type style wrapper around String,
        /// to distinguish it from other strings.
        pub struct ReplicasetId(pub String);
    }
    
    pub type Weight = f64;
    
    ////////////////////////////////////////////////////////////////////////////////
    /// Replicaset info
    #[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)]
    pub struct Replicaset {
        /// Primary identifier.
        pub replicaset_id: ReplicasetId,
    
        /// UUID used to identify replicasets by tarantool's subsystems.
        pub replicaset_uuid: String,
    
        /// Instance id of the current replication leader.
        pub current_master_id: InstanceId,
    
        /// Id of instance which should become the replication leader.
        pub target_master_id: InstanceId,
    
        /// Name of the tier the replicaset belongs to.
        pub tier: String,
    
        /// Sharding weight of the replicaset.
        ///
        /// Determines the portion of the tier's buckets which will be stored in
        /// this replicaset.
        pub weight: Weight,
    
        /// Describes how the `weight` is chosen: either automatically by governor,
        /// or manually by the user.
        pub weight_origin: WeightOrigin,
    
        /// Current state of the replicaset. This is set to `NotReady` when the
        /// replicaset is not filled up to the tier's replication factor.
        pub state: ReplicasetState,
    }
    impl Encode for Replicaset {}
    
    impl Replicaset {
        /// Index of field "replicaset_uuid" in the table _pico_replicaset format.
        ///
        /// Index of first field is 0.
        pub const FIELD_REPLICASET_UUID: u32 = 1;
    
        /// Index of field "target_master_id" in the table _pico_replicaset format.
        pub const FIELD_TARGET_MASTER_ID: u32 = 3;
    
        #[inline]
        pub fn with_one_instance(master: &Instance) -> Replicaset {
            Replicaset {
                replicaset_id: master.replicaset_id.clone(),
                replicaset_uuid: master.replicaset_uuid.clone(),
                current_master_id: master.instance_id.clone(),
                target_master_id: master.instance_id.clone(),
                weight: 0.,
                weight_origin: WeightOrigin::Auto,
                state: ReplicasetState::NotReady,