mirror of https://github.com/waku-org/nwaku.git
chore(postgres): not loading the libpq library by default & better user feedback (#2028)
* removing implicit dependency with libpq if postgres is not being used. * We only run the postgres tests when explicitly willing to, i.e. make POSTGRES=1 test. The reason is that the postgres tests expect a database instance to be running locally.
This commit is contained in:
parent
563b2b20a5
commit
e8602021b6
|
@ -117,7 +117,7 @@ jobs:
|
||||||
sudo docker run --rm -d -e POSTGRES_PASSWORD=test123 -p 5432:5432 postgres:9.6-alpine
|
sudo docker run --rm -d -e POSTGRES_PASSWORD=test123 -p 5432:5432 postgres:9.6-alpine
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 test testwakunode2
|
make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=1 test testwakunode2
|
||||||
|
|
||||||
build-docker-image:
|
build-docker-image:
|
||||||
needs: changes
|
needs: changes
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -106,6 +106,10 @@ ifneq ($(USE_LIBBACKTRACE), 0)
|
||||||
deps: | libbacktrace
|
deps: | libbacktrace
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(POSTGRES), 1)
|
||||||
|
NIM_PARAMS := $(NIM_PARAMS) -d:postgres -d:nimDebugDlOpen
|
||||||
|
endif
|
||||||
|
|
||||||
clean: | clean-libbacktrace
|
clean: | clean-libbacktrace
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,7 +222,7 @@ docs: | build deps
|
||||||
#####################
|
#####################
|
||||||
# -d:insecure - Necessary to enable Prometheus HTTP endpoint for metrics
|
# -d:insecure - Necessary to enable Prometheus HTTP endpoint for metrics
|
||||||
# -d:chronicles_colors:none - Necessary to disable colors in logs for Docker
|
# -d:chronicles_colors:none - Necessary to disable colors in logs for Docker
|
||||||
DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure
|
DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure -d:postgres
|
||||||
DOCKER_IMAGE_NIMFLAGS := $(DOCKER_IMAGE_NIMFLAGS) $(HEAPTRACK_PARAMS)
|
DOCKER_IMAGE_NIMFLAGS := $(DOCKER_IMAGE_NIMFLAGS) $(HEAPTRACK_PARAMS)
|
||||||
|
|
||||||
# build a docker image for the fleet
|
# build a docker image for the fleet
|
||||||
|
|
|
@ -21,9 +21,10 @@ import
|
||||||
./waku_archive/test_waku_archive
|
./waku_archive/test_waku_archive
|
||||||
|
|
||||||
const os* {.strdefine.} = ""
|
const os* {.strdefine.} = ""
|
||||||
when os == "Linux":
|
when os == "Linux" and
|
||||||
# GitHub only supports container actions on Linux
|
# GitHub only supports container actions on Linux
|
||||||
# and we need to start a postgress database in a docker container
|
# and we need to start a postgress database in a docker container
|
||||||
|
defined(postgres):
|
||||||
import
|
import
|
||||||
./waku_archive/test_driver_postgres_query,
|
./waku_archive/test_driver_postgres_query,
|
||||||
./waku_archive/test_driver_postgres
|
./waku_archive/test_driver_postgres
|
||||||
|
|
|
@ -14,10 +14,6 @@ import
|
||||||
../common/databases/dburl,
|
../common/databases/dburl,
|
||||||
../common/databases/db_sqlite,
|
../common/databases/db_sqlite,
|
||||||
./driver,
|
./driver,
|
||||||
./driver/queue_driver,
|
|
||||||
./driver/sqlite_driver,
|
|
||||||
./driver/sqlite_driver/migrations as archive_driver_sqlite_migrations,
|
|
||||||
./driver/postgres_driver/postgres_driver,
|
|
||||||
./retention_policy,
|
./retention_policy,
|
||||||
./retention_policy/retention_policy_capacity,
|
./retention_policy/retention_policy_capacity,
|
||||||
./retention_policy/retention_policy_time,
|
./retention_policy/retention_policy_time,
|
||||||
|
|
|
@ -14,13 +14,15 @@ import
|
||||||
../../common/databases/db_sqlite,
|
../../common/databases/db_sqlite,
|
||||||
./sqlite_driver,
|
./sqlite_driver,
|
||||||
./sqlite_driver/migrations as archive_driver_sqlite_migrations,
|
./sqlite_driver/migrations as archive_driver_sqlite_migrations,
|
||||||
./queue_driver,
|
./queue_driver
|
||||||
./postgres_driver
|
|
||||||
|
|
||||||
export
|
export
|
||||||
sqlite_driver,
|
sqlite_driver,
|
||||||
queue_driver,
|
queue_driver
|
||||||
postgres_driver
|
|
||||||
|
when defined(postgres):
|
||||||
|
import ./postgres_driver ## This import adds dependency with an external libpq library
|
||||||
|
export postgres_driver
|
||||||
|
|
||||||
proc new*(T: type ArchiveDriver,
|
proc new*(T: type ArchiveDriver,
|
||||||
url: string,
|
url: string,
|
||||||
|
@ -78,6 +80,7 @@ proc new*(T: type ArchiveDriver,
|
||||||
return ok(res.get())
|
return ok(res.get())
|
||||||
|
|
||||||
of "postgres":
|
of "postgres":
|
||||||
|
when defined(postgres):
|
||||||
const MaxNumConns = 5 #TODO: we may need to set that from app args (maybe?)
|
const MaxNumConns = 5 #TODO: we may need to set that from app args (maybe?)
|
||||||
let res = PostgresDriver.new(url, MaxNumConns, onErrAction)
|
let res = PostgresDriver.new(url, MaxNumConns, onErrAction)
|
||||||
if res.isErr():
|
if res.isErr():
|
||||||
|
@ -95,6 +98,9 @@ proc new*(T: type ArchiveDriver,
|
||||||
|
|
||||||
return ok(driver)
|
return ok(driver)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return err("Postgres has been configured but not been compiled. Check compiler definitions.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
debug "setting up in-memory waku archive driver"
|
debug "setting up in-memory waku archive driver"
|
||||||
let driver = QueueDriver.new() # Defaults to a capacity of 25.000 messages
|
let driver = QueueDriver.new() # Defaults to a capacity of 25.000 messages
|
||||||
|
|
Loading…
Reference in New Issue