Rename emgauwa-lib to emgauwa-common
This commit is contained in:
		
							parent
							
								
									6340cfd5c7
								
							
						
					
					
						commit
						9bc75b9627
					
				
					 58 changed files with 135 additions and 100 deletions
				
			
		
							
								
								
									
										33
									
								
								.forgejo/workflows/release.yaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								.forgejo/workflows/release.yaml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    tags:
 | 
				
			||||||
 | 
					      - v**
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  build-artifacts:
 | 
				
			||||||
 | 
					    runs-on: docker
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        arch:
 | 
				
			||||||
 | 
					          #- x86_64-unknown-linux-musl # for docker
 | 
				
			||||||
 | 
					          - arm-unknown-linux-gnueabihf # for raspberry pi
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - uses: https://code.forgejo.org/actions/checkout@v3
 | 
				
			||||||
 | 
					      - name: Set up Docker Buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v3
 | 
				
			||||||
 | 
					      - id: install-dependencies
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          curl https://sh.rustup.rs -sSf | sh -s -- -y
 | 
				
			||||||
 | 
					        shell: bash
 | 
				
			||||||
 | 
					      - id: cargo-build-release
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          source "$HOME/.cargo/env"
 | 
				
			||||||
 | 
					          cross build --target ${{ matrix.arch }} --release
 | 
				
			||||||
 | 
					        shell: bash
 | 
				
			||||||
 | 
					      - uses: https://code.forgejo.org/actions/upload-artifact@v3
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          name: emgauwa-core_${{ matrix.arch }}
 | 
				
			||||||
 | 
					          path: ${{ github.workspace }}/target/${{ matrix.arch }}/release/emgauwa-core
 | 
				
			||||||
 | 
					      - uses: https://code.forgejo.org/actions/upload-artifact@v3
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          name: emgauwa-controller_${{ matrix.arch }}
 | 
				
			||||||
 | 
					          path: ${{ github.workspace }}/target/${{ matrix.arch }}/release/emgauwa-controller
 | 
				
			||||||
							
								
								
									
										52
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										52
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -699,13 +699,37 @@ dependencies = [
 | 
				
			||||||
 "serde",
 | 
					 "serde",
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[package]]
 | 
				
			||||||
 | 
					name = "emgauwa-common"
 | 
				
			||||||
 | 
					version = "0.5.0"
 | 
				
			||||||
 | 
					dependencies = [
 | 
				
			||||||
 | 
					 "actix",
 | 
				
			||||||
 | 
					 "actix-web",
 | 
				
			||||||
 | 
					 "actix-web-actors",
 | 
				
			||||||
 | 
					 "chrono",
 | 
				
			||||||
 | 
					 "config",
 | 
				
			||||||
 | 
					 "futures",
 | 
				
			||||||
 | 
					 "libc",
 | 
				
			||||||
 | 
					 "libsqlite3-sys",
 | 
				
			||||||
 | 
					 "log",
 | 
				
			||||||
 | 
					 "rppal 0.17.1",
 | 
				
			||||||
 | 
					 "rppal-mcp23s17",
 | 
				
			||||||
 | 
					 "rppal-pfd",
 | 
				
			||||||
 | 
					 "serde",
 | 
				
			||||||
 | 
					 "serde_derive",
 | 
				
			||||||
 | 
					 "serde_json",
 | 
				
			||||||
 | 
					 "simple_logger",
 | 
				
			||||||
 | 
					 "sqlx",
 | 
				
			||||||
 | 
					 "uuid",
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "emgauwa-controller"
 | 
					name = "emgauwa-controller"
 | 
				
			||||||
version = "0.5.0"
 | 
					version = "0.5.0"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "actix",
 | 
					 "actix",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 "emgauwa-lib",
 | 
					 "emgauwa-common",
 | 
				
			||||||
 "futures",
 | 
					 "futures",
 | 
				
			||||||
 "futures-channel",
 | 
					 "futures-channel",
 | 
				
			||||||
 "log",
 | 
					 "log",
 | 
				
			||||||
| 
						 | 
					@ -731,7 +755,7 @@ dependencies = [
 | 
				
			||||||
 "actix-web",
 | 
					 "actix-web",
 | 
				
			||||||
 "actix-web-actors",
 | 
					 "actix-web-actors",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 "emgauwa-lib",
 | 
					 "emgauwa-common",
 | 
				
			||||||
 "futures",
 | 
					 "futures",
 | 
				
			||||||
 "itertools 0.12.1",
 | 
					 "itertools 0.12.1",
 | 
				
			||||||
 "log",
 | 
					 "log",
 | 
				
			||||||
| 
						 | 
					@ -745,30 +769,6 @@ dependencies = [
 | 
				
			||||||
 "uuid",
 | 
					 "uuid",
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					 | 
				
			||||||
name = "emgauwa-lib"
 | 
					 | 
				
			||||||
version = "0.5.0"
 | 
					 | 
				
			||||||
dependencies = [
 | 
					 | 
				
			||||||
 "actix",
 | 
					 | 
				
			||||||
 "actix-web",
 | 
					 | 
				
			||||||
 "actix-web-actors",
 | 
					 | 
				
			||||||
 "chrono",
 | 
					 | 
				
			||||||
 "config",
 | 
					 | 
				
			||||||
 "futures",
 | 
					 | 
				
			||||||
 "libc",
 | 
					 | 
				
			||||||
 "libsqlite3-sys",
 | 
					 | 
				
			||||||
 "log",
 | 
					 | 
				
			||||||
 "rppal 0.17.1",
 | 
					 | 
				
			||||||
 "rppal-mcp23s17",
 | 
					 | 
				
			||||||
 "rppal-pfd",
 | 
					 | 
				
			||||||
 "serde",
 | 
					 | 
				
			||||||
 "serde_derive",
 | 
					 | 
				
			||||||
 "serde_json",
 | 
					 | 
				
			||||||
 "simple_logger",
 | 
					 | 
				
			||||||
 "sqlx",
 | 
					 | 
				
			||||||
 "uuid",
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "encoding_rs"
 | 
					name = "encoding_rs"
 | 
				
			||||||
version = "0.8.33"
 | 
					version = "0.8.33"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,5 +3,5 @@ resolver = "2"
 | 
				
			||||||
members = [
 | 
					members = [
 | 
				
			||||||
    "emgauwa-core",
 | 
					    "emgauwa-core",
 | 
				
			||||||
    "emgauwa-controller",
 | 
					    "emgauwa-controller",
 | 
				
			||||||
    "emgauwa-lib",
 | 
					    "emgauwa-common",
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "emgauwa-lib"
 | 
					name = "emgauwa-common"
 | 
				
			||||||
version = "0.5.0"
 | 
					version = "0.5.0"
 | 
				
			||||||
edition = "2021"
 | 
					edition = "2021"
 | 
				
			||||||
authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
					authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ edition = "2021"
 | 
				
			||||||
authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
					authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
emgauwa-lib = { path = "../emgauwa-lib" }
 | 
					emgauwa-common = { path = "../emgauwa-common" }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
actix = "0.13"
 | 
					actix = "0.13"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,11 +2,11 @@ use std::sync::Arc;
 | 
				
			||||||
use std::time::{Duration, Instant};
 | 
					use std::time::{Duration, Instant};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use actix::{Actor, Context, Handler, Message};
 | 
					use actix::{Actor, Context, Handler, Message};
 | 
				
			||||||
use emgauwa_lib::constants;
 | 
					use emgauwa_common::constants;
 | 
				
			||||||
use emgauwa_lib::drivers::RelayDriver;
 | 
					use emgauwa_common::drivers::RelayDriver;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::models::Controller;
 | 
					use emgauwa_common::models::Controller;
 | 
				
			||||||
use emgauwa_lib::types::RelayStates;
 | 
					use emgauwa_common::types::RelayStates;
 | 
				
			||||||
use futures::executor::block_on;
 | 
					use futures::executor::block_on;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
use tokio::sync::Notify;
 | 
					use tokio::sync::Notify;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,10 @@
 | 
				
			||||||
use actix::Actor;
 | 
					use actix::Actor;
 | 
				
			||||||
use emgauwa_lib::db;
 | 
					use emgauwa_common::db;
 | 
				
			||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
					use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::models::{Controller, FromDbModel};
 | 
					use emgauwa_common::models::{Controller, FromDbModel};
 | 
				
			||||||
use emgauwa_lib::types::EmgauwaUid;
 | 
					use emgauwa_common::types::EmgauwaUid;
 | 
				
			||||||
use emgauwa_lib::utils::{drop_privileges, init_logging};
 | 
					use emgauwa_common::utils::{drop_privileges, init_logging};
 | 
				
			||||||
use rppal_pfd::PiFaceDigital;
 | 
					use rppal_pfd::PiFaceDigital;
 | 
				
			||||||
use sqlx::pool::PoolConnection;
 | 
					use sqlx::pool::PoolConnection;
 | 
				
			||||||
use sqlx::Sqlite;
 | 
					use sqlx::Sqlite;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,11 +2,11 @@ use std::time::{Duration, Instant};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use chrono::{Local, Timelike};
 | 
					use chrono::{Local, Timelike};
 | 
				
			||||||
use emgauwa_lib::constants::RELAYS_RETRY_TIMEOUT;
 | 
					use emgauwa_common::constants::RELAYS_RETRY_TIMEOUT;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::models::Controller;
 | 
					use emgauwa_common::models::Controller;
 | 
				
			||||||
use emgauwa_lib::types::{RelayStates, Weekday};
 | 
					use emgauwa_common::types::{RelayStates, Weekday};
 | 
				
			||||||
use emgauwa_lib::utils::printable_relay_states;
 | 
					use emgauwa_common::utils::printable_relay_states;
 | 
				
			||||||
use futures::pin_mut;
 | 
					use futures::pin_mut;
 | 
				
			||||||
use tokio::time;
 | 
					use tokio::time;
 | 
				
			||||||
use tokio::time::timeout;
 | 
					use tokio::time::timeout;
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ pub async fn run_relays_loop(app_state: Addr<AppState>) {
 | 
				
			||||||
async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
 | 
					async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
 | 
				
			||||||
	let notifier = &*app_state_get_controller_notifier(app_state).await?;
 | 
						let notifier = &*app_state_get_controller_notifier(app_state).await?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let mut last_weekday = emgauwa_lib::utils::get_weekday();
 | 
						let mut last_weekday = emgauwa_common::utils::get_weekday();
 | 
				
			||||||
	let mut this = utils::app_state_get_this(app_state).await?;
 | 
						let mut this = utils::app_state_get_this(app_state).await?;
 | 
				
			||||||
	let mut relay_states: RelayStates = Vec::new();
 | 
						let mut relay_states: RelayStates = Vec::new();
 | 
				
			||||||
	init_relay_states(&mut relay_states, &this);
 | 
						init_relay_states(&mut relay_states, &this);
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,7 @@ async fn check_weekday(
 | 
				
			||||||
	last_weekday: &mut Weekday,
 | 
						last_weekday: &mut Weekday,
 | 
				
			||||||
	changed: &mut bool,
 | 
						changed: &mut bool,
 | 
				
			||||||
) -> Result<(), EmgauwaError> {
 | 
					) -> Result<(), EmgauwaError> {
 | 
				
			||||||
	let current_weekday = emgauwa_lib::utils::get_weekday();
 | 
						let current_weekday = emgauwa_common::utils::get_weekday();
 | 
				
			||||||
	if current_weekday.ne(last_weekday) {
 | 
						if current_weekday.ne(last_weekday) {
 | 
				
			||||||
		log::debug!("Weekday changed");
 | 
							log::debug!("Weekday changed");
 | 
				
			||||||
		*last_weekday = current_weekday;
 | 
							*last_weekday = current_weekday;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::{drivers, settings};
 | 
					use emgauwa_common::{drivers, settings};
 | 
				
			||||||
use rppal_pfd::PiFaceDigital;
 | 
					use rppal_pfd::PiFaceDigital;
 | 
				
			||||||
use serde_derive::Deserialize;
 | 
					use serde_derive::Deserialize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use std::sync::Arc;
 | 
					use std::sync::Arc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::models::Controller;
 | 
					use emgauwa_common::models::Controller;
 | 
				
			||||||
use emgauwa_lib::types::RelayStates;
 | 
					use emgauwa_common::types::RelayStates;
 | 
				
			||||||
use tokio::sync::Notify;
 | 
					use tokio::sync::Notify;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::app_state;
 | 
					use crate::app_state;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use emgauwa_lib::constants::WEBSOCKET_RETRY_TIMEOUT;
 | 
					use emgauwa_common::constants::WEBSOCKET_RETRY_TIMEOUT;
 | 
				
			||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
					use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{Controller, Relay};
 | 
					use emgauwa_common::models::{Controller, Relay};
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, ScheduleUid};
 | 
					use emgauwa_common::types::{ControllerWsAction, ScheduleUid};
 | 
				
			||||||
use futures::{future, pin_mut, SinkExt, StreamExt};
 | 
					use futures::{future, pin_mut, SinkExt, StreamExt};
 | 
				
			||||||
use sqlx::pool::PoolConnection;
 | 
					use sqlx::pool::PoolConnection;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ edition = "2021"
 | 
				
			||||||
authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
					authors = ["Tobias Reisinger <tobias@msrg.cc>"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies]
 | 
					[dependencies]
 | 
				
			||||||
emgauwa-lib = { path = "../emgauwa-lib" }
 | 
					emgauwa-common = { path = "../emgauwa-common" }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
actix = "0.13"
 | 
					actix = "0.13"
 | 
				
			||||||
actix-web = "4.4"
 | 
					actix-web = "4.4"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,10 @@
 | 
				
			||||||
use std::collections::HashMap;
 | 
					use std::collections::HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use actix::{Actor, Addr, Context, Handler, Message, Recipient};
 | 
					use actix::{Actor, Addr, Context, Handler, Message, Recipient};
 | 
				
			||||||
use emgauwa_lib::db::DbController;
 | 
					use emgauwa_common::db::DbController;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::models::{convert_db_list, Controller, Relay};
 | 
					use emgauwa_common::models::{convert_db_list, Controller, Relay};
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RelayStates};
 | 
					use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RelayStates};
 | 
				
			||||||
use futures::executor::block_on;
 | 
					use futures::executor::block_on;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use actix_web::{delete, get, put, web, HttpResponse};
 | 
					use actix_web::{delete, get, put, web, HttpResponse};
 | 
				
			||||||
use emgauwa_lib::db::DbController;
 | 
					use emgauwa_common::db::DbController;
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{convert_db_list, Controller, FromDbModel};
 | 
					use emgauwa_common::models::{convert_db_list, Controller, FromDbModel};
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RequestControllerUpdate};
 | 
					use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RequestControllerUpdate};
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::app_state;
 | 
					use crate::app_state;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use actix_web::{delete, get, post, put, web, HttpResponse};
 | 
					use actix_web::{delete, get, post, put, web, HttpResponse};
 | 
				
			||||||
use emgauwa_lib::db::DbMacro;
 | 
					use emgauwa_common::db::DbMacro;
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay};
 | 
					use emgauwa_common::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay};
 | 
				
			||||||
use emgauwa_lib::types::{
 | 
					use emgauwa_common::types::{
 | 
				
			||||||
	ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate,
 | 
						ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use itertools::Itertools;
 | 
					use itertools::Itertools;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,12 @@
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use actix_web::{get, post, put, web, HttpResponse};
 | 
					use actix_web::{get, post, put, web, HttpResponse};
 | 
				
			||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag};
 | 
					use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag};
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{convert_db_list, FromDbModel, Relay};
 | 
					use emgauwa_common::models::{convert_db_list, FromDbModel, Relay};
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RequestRelayPulse, RequestRelayUpdate};
 | 
					use emgauwa_common::types::{
 | 
				
			||||||
use emgauwa_lib::utils;
 | 
						ControllerWsAction, EmgauwaUid, RequestRelayPulse, RequestRelayUpdate,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					use emgauwa_common::utils;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::app_state;
 | 
					use crate::app_state;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use actix_web::{delete, get, post, put, web, HttpResponse};
 | 
					use actix_web::{delete, get, post, put, web, HttpResponse};
 | 
				
			||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag};
 | 
					use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag};
 | 
				
			||||||
use emgauwa_lib::errors::{ApiError, DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{ApiError, DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{convert_db_list, FromDbModel, Schedule};
 | 
					use emgauwa_common::models::{convert_db_list, FromDbModel, Schedule};
 | 
				
			||||||
use emgauwa_lib::types::{
 | 
					use emgauwa_common::types::{
 | 
				
			||||||
	ControllerWsAction, RequestScheduleCreate, RequestScheduleUpdate, ScheduleUid,
 | 
						ControllerWsAction, RequestScheduleCreate, RequestScheduleUpdate, ScheduleUid,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use itertools::Itertools;
 | 
					use itertools::Itertools;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
use actix_web::{delete, get, post, web, HttpResponse};
 | 
					use actix_web::{delete, get, post, web, HttpResponse};
 | 
				
			||||||
use emgauwa_lib::db::DbTag;
 | 
					use emgauwa_common::db::DbTag;
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{FromDbModel, Tag};
 | 
					use emgauwa_common::models::{FromDbModel, Tag};
 | 
				
			||||||
use emgauwa_lib::types::RequestTagCreate;
 | 
					use emgauwa_common::types::RequestTagCreate;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[get("/tags")]
 | 
					#[get("/tags")]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
use actix::{Actor, AsyncContext};
 | 
					use actix::{Actor, AsyncContext};
 | 
				
			||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
					use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule};
 | 
				
			||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
 | 
					use emgauwa_common::errors::{DatabaseError, EmgauwaError};
 | 
				
			||||||
use emgauwa_lib::models::{Controller, FromDbModel};
 | 
					use emgauwa_common::models::{Controller, FromDbModel};
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RelayStates};
 | 
					use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RelayStates};
 | 
				
			||||||
use emgauwa_lib::utils;
 | 
					use emgauwa_common::utils;
 | 
				
			||||||
use futures::executor::block_on;
 | 
					use futures::executor::block_on;
 | 
				
			||||||
use sqlx::pool::PoolConnection;
 | 
					use sqlx::pool::PoolConnection;
 | 
				
			||||||
use sqlx::Sqlite;
 | 
					use sqlx::Sqlite;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,9 +5,9 @@ use std::time::Instant;
 | 
				
			||||||
use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, StreamHandler};
 | 
					use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, StreamHandler};
 | 
				
			||||||
use actix_web_actors::ws;
 | 
					use actix_web_actors::ws;
 | 
				
			||||||
use actix_web_actors::ws::ProtocolError;
 | 
					use actix_web_actors::ws::ProtocolError;
 | 
				
			||||||
use emgauwa_lib::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT};
 | 
					use emgauwa_common::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT};
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid};
 | 
					use emgauwa_common::types::{ControllerWsAction, EmgauwaUid};
 | 
				
			||||||
use futures::executor::block_on;
 | 
					use futures::executor::block_on;
 | 
				
			||||||
use sqlx::pool::PoolConnection;
 | 
					use sqlx::pool::PoolConnection;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@ use std::time::Instant;
 | 
				
			||||||
use actix::Addr;
 | 
					use actix::Addr;
 | 
				
			||||||
use actix_web::{get, web, HttpRequest, HttpResponse};
 | 
					use actix_web::{get, web, HttpRequest, HttpResponse};
 | 
				
			||||||
use actix_web_actors::ws;
 | 
					use actix_web_actors::ws;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use sqlx::{Pool, Sqlite};
 | 
					use sqlx::{Pool, Sqlite};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::app_state::AppState;
 | 
					use crate::app_state::AppState;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,8 +3,8 @@ use std::time::Instant;
 | 
				
			||||||
use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Message, StreamHandler};
 | 
					use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Message, StreamHandler};
 | 
				
			||||||
use actix_web_actors::ws;
 | 
					use actix_web_actors::ws;
 | 
				
			||||||
use actix_web_actors::ws::ProtocolError;
 | 
					use actix_web_actors::ws::ProtocolError;
 | 
				
			||||||
use emgauwa_lib::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT};
 | 
					use emgauwa_common::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT};
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use futures::executor::block_on;
 | 
					use futures::executor::block_on;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::app_state::{AppState, ConnectRelayClient};
 | 
					use crate::app_state::{AppState, ConnectRelayClient};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,9 +4,9 @@ use actix::{Actor, Arbiter};
 | 
				
			||||||
use actix_cors::Cors;
 | 
					use actix_cors::Cors;
 | 
				
			||||||
use actix_web::middleware::TrailingSlash;
 | 
					use actix_web::middleware::TrailingSlash;
 | 
				
			||||||
use actix_web::{middleware, web, App, HttpServer};
 | 
					use actix_web::{middleware, web, App, HttpServer};
 | 
				
			||||||
use emgauwa_lib::db::DbController;
 | 
					use emgauwa_common::db::DbController;
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::utils::{drop_privileges, init_logging};
 | 
					use emgauwa_common::utils::{drop_privileges, init_logging};
 | 
				
			||||||
use serde_json::json;
 | 
					use serde_json::json;
 | 
				
			||||||
use utoipa_swagger_ui::SwaggerUi;
 | 
					use utoipa_swagger_ui::SwaggerUi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ async fn main() -> Result<(), std::io::Error> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	init_logging(&settings.logging.level)?;
 | 
						init_logging(&settings.logging.level)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let pool = emgauwa_lib::db::init(&settings.database).await?;
 | 
						let pool = emgauwa_common::db::init(&settings.database).await?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let mut conn = pool.acquire().await.map_err(EmgauwaError::from)?;
 | 
						let mut conn = pool.acquire().await.map_err(EmgauwaError::from)?;
 | 
				
			||||||
	DbController::all_inactive(&mut conn)
 | 
						DbController::all_inactive(&mut conn)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use emgauwa_lib::errors::EmgauwaError;
 | 
					use emgauwa_common::errors::EmgauwaError;
 | 
				
			||||||
use emgauwa_lib::settings;
 | 
					use emgauwa_common::settings;
 | 
				
			||||||
use serde_derive::Deserialize;
 | 
					use serde_derive::Deserialize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Clone, Debug, Deserialize)]
 | 
					#[derive(Clone, Debug, Deserialize)]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue