Comments (1)
It sounds like you are describing a system for dynamically pausing and unpausing services in order to improve the scalability of services-per-node. In this system, services can be paused by removing them without removing their disk state, and then started again on demand. The paused service queue would retain calls sent to the service before it is unpaused, and it would be possible to get the state of a service (paused, awake, or non-existent). Some services may be marked as unpausable, such as built-in services or services used by scheduled scripts.
To implement this system, you may want to consider the following steps:
- Implement a way to pause and unpause services by removing and starting them without removing their disk state.
- Implement a paused service queue to retain calls made to paused services.
- Implement a way to get the interface of a service without waking it up.
- Implement a way to get the state of a service (paused, awake, or non-existent).
- Mark some services as unpausable if necessary.
It is important to keep in mind that services should be ready to be restarted in the event of a node reboot, so they should be designed to handle being paused and unpaused. You may want to measure how long it takes to unpause and start a service to understand whether this approach is viable. It is also possible that you may need to cache compiled WASM code to improve performance.
In the documentation for your system, you should explain that services should be ready to be restarted in order to be compatible with the pausing and unpausing system. This will help users understand the requirements for using this feature.
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
struct Service {
// Other fields for the service go here...
// Flag to indicate whether the service is paused
paused: bool,
}
struct PausedServiceQueue {
// Map of service ID to the calls made to the service while it was paused
queue: HashMap<String, Vec<String>>,
}
impl PausedServiceQueue {
fn new() -> Self {
PausedServiceQueue {
queue: HashMap::new(),
}
}
fn add_call(&mut self, service_id: String, call: String) {
self.queue.entry(service_id).or_default().push(call);
}
fn remove_calls(&mut self, service_id: &str) -> Vec<String> {
self.queue.remove(service_id).unwrap_or_default()
}
}
struct ServiceManager {
services: HashMap<String, Arc<Mutex<Service>>>,
paused_services: Arc<Mutex<PausedServiceQueue>>,
}
impl ServiceManager {
fn new() -> Self {
ServiceManager {
services: HashMap::new(),
paused_services: Arc::new(Mutex::new(PausedServiceQueue::new())),
}
}
fn add_service(&mut self, service_id: String, service: Service) {
self.services.insert(service_id, Arc::new(Mutex::new(service)));
}
fn pause_service(&mut self, service_id: &str) {
let service = self.services.get_mut(service_id).unwrap();
let mut service = service.lock().unwrap();
service.paused = true;
}
fn unpause_service(&mut self, service_id: &str) {
let service = self.services.get_mut(service_id
from nox.
Related Issues (20)
- Builtins: add namespaced cache
- Services: separate effectors from pure modules
- Collect services' logs and provide API to download them
- DX: All keys should be in base64
- Builtins: add Time namespace
- Metrics: collect and expose queue sizes HOT 1
- Protocol: add means to control version-compatibility between AIR update HOT 2
- Stability: run test suite once a day against testnet and Krasnodar
- Stability: periodic healthchecks
- Security: add option to restrict service deployment to node admin
- Add `debug stringify` service HOT 1
- Add `srv status` and/or `srv exists` builtin
- Integration tests with p2p connectivity often hang HOT 1
- Disable tide logs HOT 1
- LibP2P Protocol: unexpected EOF when reading incoming ProtocolMessage HOT 1
- It's impossible to say which scheduled script triggered which particle HOT 1
- Move from CIrcleCI to GitHub Actions HOT 1
- Dependency Dashboard
- Expres HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nox.