Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host list #19

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ target/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.vscode/
37 changes: 37 additions & 0 deletions build/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: "3.8"
services:
proxysql:
image: proxysql/proxysql
ports:
- "6033:6033"
- "6032:6032"
volumes:
- ./proxysql.cnf:/etc/proxysql.cnf
mysql-master:
image: mysql:8.0
container_name: mysql-master
environment:
- MYSQL_ROOT_PASSWORD=noria
- MYSQL_DATABASE=noria
command: --server-id=1
ports:
- "3306:3306"
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -u root -pnoria"]
interval: 10s
retries: 20
start_period: 30s
timeout: 10s
readyset:
image: readysettech/readyset
ports:
- "3307:3307"
- "6034:6034"
environment:
- UPSTREAM_DB_URL=mysql://root:[email protected]:3306/noria
- LISTEN_ADDRESS=0.0.0.0:3307
depends_on:
mysql-master:
condition: service_healthy
restart: true

30 changes: 30 additions & 0 deletions build/proxysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
admin_variables=
{
admin_credentials="admin:admin;radmin:radmin"
}

# defines all the MySQL servers
mysql_servers =
(
{ address="host.docker.internal" , port=3306 , hostgroup=1, comment="Source" },
{ address="host.docker.internal" , port=3307 , hostgroup=2, weight=1000, comment="Readyset" },
{ address="host.docker.internal" , port=3306 , hostgroup=2, weight=1, comment="Source" }
)

mysql_variables=
{
monitor_username="root"
monitor_password="noria"
}

mysql_users:
altmannmarcelo marked this conversation as resolved.
Show resolved Hide resolved
(
{
username = "root"
password = "noria"
default_hostgroup = 1
max_connections=1000
default_schema="noria"
active = 1
}
)
12 changes: 12 additions & 0 deletions build/test.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
proxysql_user = 'radmin'
proxysql_password = 'radmin'
proxysql_host = '127.0.0.1'
proxysql_port = 6032
readyset_user = 'root'
readyset_password = 'noria'
source_hostgroup = 1
readyset_hostgroup = 2
warmup_time = 60
lock_file = '/tmp/readyset_scheduler.lock'
operation_mode="All"
number_of_queries=10
2 changes: 0 additions & 2 deletions readyset_proxysql_scheduler.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ proxysql_host = '127.0.0.1'
proxysql_port = 6032
readyset_user = 'root'
readyset_password = 'root'
readyset_host = '127.0.0.1'
readyset_port = 3307
source_hostgroup = 11
readyset_hostgroup = 99
warmup_time = 60
Expand Down
2 changes: 0 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ pub struct Config {
pub proxysql_port: u16,
pub readyset_user: String,
pub readyset_password: String,
pub readyset_host: String,
pub readyset_port: u16,
pub source_hostgroup: u16,
pub readyset_hostgroup: u16,
pub warmup_time: Option<u16>,
Expand Down
21 changes: 8 additions & 13 deletions src/health_check.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
use crate::{
config, messages,
server::{self, ServerStatus},
config,
hosts::{Host, HostStatus},
messages,
};

pub fn health_check(
proxysql_conn: &mut mysql::PooledConn,
config: &config::Config,
readyset_conn: &mut mysql::PooledConn,
) {
match server::check_readyset_is_ready(readyset_conn) {
pub fn health_check(proxysql_conn: &mut mysql::Conn, config: &config::Config, host: &mut Host) {
match host.check_readyset_is_ready() {
Ok(ready) => {
if ready {
let _ = server::change_server_status(proxysql_conn, config, ServerStatus::Online);
let _ = host.change_status(proxysql_conn, config, HostStatus::Online);
} else {
messages::print_info("Readyset is still running Snapshot.");
let _ = server::change_server_status(proxysql_conn, config, ServerStatus::Shunned);
std::process::exit(0);
let _ = host.change_status(proxysql_conn, config, HostStatus::Shunned);
}
}
Err(e) => {
messages::print_error(format!("Cannot check Readyset status: {}.", e).as_str());
let _ = server::change_server_status(proxysql_conn, config, ServerStatus::Shunned);
std::process::exit(1);
let _ = host.change_status(proxysql_conn, config, HostStatus::Shunned);
}
};
}
Loading