refactor: уникальные имена функций-обработчиков

handle() → run_sql()    (sql_runner.py,  entrypoint: sql_runner.run_sql)
handle() → crud()       (notes_crud.py,  entrypoint: notes_crud.crud)
handle() → list_notes() (notes_list.py,  entrypoint: notes_list.list_notes)
This commit is contained in:
“Naeel” 2026-03-09 10:14:36 +04:00
parent 49035d35f0
commit 74d288c7a7
9 changed files with 9 additions and 9 deletions

View File

@ -15,7 +15,7 @@ import psycopg2
import psycopg2.extras
def handle(event):
def list_notes(event):
dsn = os.environ['PG_DSN']
conn = psycopg2.connect(dsn)
try:

View File

@ -17,7 +17,7 @@ import psycopg2
import psycopg2.extras
def handle(event):
def crud(event):
dsn = os.environ['PG_DSN']
# sub-path без ведущего слэша: "add", "update", "delete"
action = event.get('_path', '/').strip('/')

View File

@ -19,7 +19,7 @@ import os
import psycopg2
def handle(event):
def run_sql(event):
dsn = os.environ['PG_DSN']
statements = event.get('statements', [])
if not statements:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,12 +16,12 @@ data "archive_file" "notes_list_zip" {
}
# Read-only функция в кластере.
# entrypoint = "notes_list.handle" файл notes_list.py, функция handle().
# entrypoint = "notes_list.list_notes" файл notes_list.py, функция list_notes().
resource "sless_function" "notes_list" {
namespace = "default"
name = "notes-list"
runtime = "python3.11"
entrypoint = "notes_list.handle"
entrypoint = "notes_list.list_notes"
memory_mb = 128
timeout_sec = 30

View File

@ -18,12 +18,12 @@ data "archive_file" "notes_crud_zip" {
}
# CRUD функция в кластере.
# entrypoint = "notes_crud.handle" файл notes_crud.py, функция handle().
# entrypoint = "notes_crud.crud" файл notes_crud.py, функция crud().
resource "sless_function" "notes_crud" {
namespace = "default"
name = "notes"
runtime = "python3.11"
entrypoint = "notes_crud.handle"
entrypoint = "notes_crud.crud"
memory_mb = 128
timeout_sec = 30

View File

@ -14,13 +14,13 @@ data "archive_file" "sql_runner_zip" {
}
# Сама функция в кластере.
# entrypoint = "sql_runner.handle" файл sql_runner.py, функция handle().
# entrypoint = "sql_runner.run_sql" файл sql_runner.py, функция run_sql().
# memory_mb=128 достаточно DDL запросы не требуют памяти на вычисления.
resource "sless_function" "sql_runner" {
namespace = "default"
name = "sql-runner"
runtime = "python3.11"
entrypoint = "sql_runner.handle"
entrypoint = "sql_runner.run_sql"
memory_mb = 128
timeout_sec = 30