A general purpose package for Dankegongyu business intelligence unit.
You can install the development version of dkbi from internal RStudio package manager.
install.packages("dkbi", repos = "<internal-cran>")
By default, dkbi
will look for an consul
object in your R global environment. It is recommended to set the following system variables in your .Renviron
file.
consul.host = "some host"
consul.port = "some port"
consul.swagger = "some swagger"
consul.secret = "some secret"
dkbi
helps to fetch values from KV store and make connection to databases.
library(dkbi)
# initiate config.R to specific path
init_config(path = "R/")
# source configs
source("R/config.R")
# make connection to database
est_mysql_conn("Forecast")
<MySQLConnection:0,0>
# fetch parameters from KV store
get_batch_kv("some_api_params", "host", "port", "swagger")
$host
[1] "some_api_host"
$port
[1] "some_api_port"
$swagger
[1] "some_api_swagger"
library(dkbi)
ls('package:dkbi')
#> [1] "est_mongo_conn" "est_mysql_conn" "get_batch_kv" "get_kv"
#> [5] "init_config" "init_plumber" "init_script"