-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBAI-29 Canister Implementation (#37)
* DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * testing if this solution works * added default value * Update tests.yml * added config loglevel * config loglevel updated * updated test.yml * updated env * updated env * updated env * Update tests.yml * TYPE added * upd type * upd type * upd yaml * some more clean up * Update services.rb * removed config dependencies * removed config dependencies * updated gem version and removed canister reg for logger * Fix missed usage of get_value without key * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * code cleanup * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * DBAI-29 Canister Implementation * code cleanup * code cleanup * code clean up * code clean up * Added loglevel method --------- Co-authored-by: Samuel Sciolla <ssciolla@umich.edu>
- Loading branch information
1 parent
47b8695
commit 824edd5
Showing
18 changed files
with
96 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "canister" | ||
require "semantic_logger" | ||
require "sequel" | ||
|
||
require_relative "lib/config" | ||
|
||
Services = Canister.new | ||
|
||
S = Services | ||
|
||
# Config | ||
S.register(:config) do | ||
Config::ConfigService.from_env | ||
end | ||
|
||
S.register(:db_config) do | ||
Config::ConfigService.database_config_from_env | ||
end | ||
|
||
# Logger | ||
module DarkBlueLogger | ||
def self.included(klass) | ||
klass.class_exec do | ||
include SemanticLogger | ||
include SemanticLogger::Loggable | ||
logger = SemanticLogger[klass] | ||
if !SemanticLogger::Logger.processor.appenders.console_output? | ||
SemanticLogger.add_appender(io: $stderr, formatter: :color) | ||
SemanticLogger.default_level = Config::ConfigService.log_level_from_env | ||
end | ||
logger | ||
end | ||
end | ||
end | ||
|
||
# Database Connection | ||
S.register(:dbconnect) do | ||
db_config = S.db_config | ||
Sequel.connect(adapter: "mysql2", | ||
host: db_config.host, | ||
port: db_config.port, | ||
database: db_config.database, | ||
user: db_config.user, | ||
password: db_config.password, | ||
fractional_seconds: true) | ||
end |
Oops, something went wrong.