Skip to content

Instantly share code, notes, and snippets.

@spbnick
Created July 10, 2023 07:29
Show Gist options
  • Save spbnick/d21194764fec41188294c6a5666ff4ee to your computer and use it in GitHub Desktop.
Save spbnick/d21194764fec41188294c6a5666ff4ee to your computer and use it in GitHub Desktop.
diff --git a/env.yaml b/env.yaml
index 4d25ae9..8a585ee 100644
--- a/env.yaml
+++ b/env.yaml
@@ -8,7 +8,7 @@ KCIDB_LOAD_QUEUE_OBJ_MAX: '8192'
KCIDB_LOAD_QUEUE_SUBSCRIPTION: kcidb_new_load
KCIDB_LOAD_QUEUE_TIMEOUT_SEC: '30'
KCIDB_LOAD_QUEUE_TOPIC: kcidb_new
-KCIDB_LOG_LEVEL: INFO
+KCIDB_LOG_LEVEL: DEBUG
KCIDB_PGPASS_SECRET: kcidb_psql_submitter_pgpass
KCIDB_SELECTED_SUBSCRIPTIONS: ''
KCIDB_SMTP_FROM_ADDR: bot@kernelci.org
diff --git a/kcidb/__init__.py b/kcidb/__init__.py
index bcaddab..9a235e0 100644
--- a/kcidb/__init__.py
+++ b/kcidb/__init__.py
@@ -6,6 +6,7 @@ import logging
from kcidb.misc import LIGHT_ASSERTS
# Silence flake8 "imported but unused" warning
from kcidb import io, db, mq, orm, oo, monitor, tests, unittest, misc # noqa
+from kcidb import cache # noqa
# Module's logger
diff --git a/main.py b/main.py
index 951a9b3..319d01f 100644
--- a/main.py
+++ b/main.py
@@ -7,7 +7,6 @@ import datetime
import logging
import smtplib
import kcidb
-from kcidb.cache import Client
# Name of the Google Cloud project we're deployed in
PROJECT_ID = os.environ["GCP_PROJECT"]
@@ -351,12 +350,14 @@ def send_message(message):
smtp.quit()
-def get_cache():
- """Create the cache instance."""
+def get_cache_client():
+ """Create the cache client."""
# It's alright, pylint: disable=global-statement
global _CACHE_CLIENT
if _CACHE_CLIENT is None:
- _CACHE_CLIENT = Client("cache_file_storage", 5 * 1024 * 1024)
+ _CACHE_CLIENT = kcidb.cache.Client(
+ "cache_file_storage", 5 * 1024 * 1024
+ )
return _CACHE_CLIENT
@@ -375,8 +376,8 @@ def kcidb_cache_urls(event, context):
# Extract the Pub/Sub message data
pubsub_message = base64.b64decode(event['data']).decode()
- # Get or create the cache instance
- cache = get_cache()
+ # Get or create the cache client
+ cache = get_cache_client()
# Cache each URL
for url in pubsub_message.splitlines():
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment