Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #662 from brian-js/caching
Browse files Browse the repository at this point in the history
Enable caching in RoutingNode.
  • Loading branch information
Benjamin Bollen committed Sep 7, 2015
2 parents 9dd79ff + bdd5734 commit a219ddb
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 45 deletions.
2 changes: 2 additions & 0 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use messages::{SignedMessage, Content};
use authority::Authority;
use types::CacheOptions;

/// An Action initiates a message flow < A | B > where we are (a part of) A.
/// 1. Action::SendMessage hands a fully formed SignedMessage over to RoutingNode
Expand All @@ -36,6 +37,7 @@ pub enum Action {
// | the destination authority
// RoutingNode will form the RoutingMessage and sign it as its own identity
Churn(::direct_messages::Churn, Vec<::crust::Endpoint>),
SetCacheOptions(CacheOptions),
WakeUp,
Terminate,
}
1 change: 1 addition & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl Data {

#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, RustcEncodable, RustcDecodable)]
pub enum DataRequest {
// (Identifier, TypeTag) pair for name resolution.
StructuredData(NameType, u64),
ImmutableData(NameType, ImmutableDataType),
PlainData(NameType),
Expand Down
8 changes: 7 additions & 1 deletion src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use messages::SignedToken;
use routing_node::RoutingNode;
use NameType;
use data::{Data, DataRequest};
use types::Bytes;
use types::{Bytes, CacheOptions};
use error::{RoutingError, ResponseError};
use authority::Authority;
use sodiumoxide::crypto;
Expand Down Expand Up @@ -155,6 +155,12 @@ impl Routing {

}

/// Dynamically enable/disable caching for Data types.
pub fn set_cache_options(&self, cache_options: CacheOptions) {
let _ = self.action_sender.send(Action::SetCacheOptions(cache_options));

}

/// Signal to RoutingNode that it needs to refuse new messages and handle all outstanding
/// messages. After handling all messages it will send an Event::Terminated to the user.
pub fn stop(&mut self) {
Expand Down
Loading

0 comments on commit a219ddb

Please sign in to comment.