refactor: notes-python — описательные имена файлов/ресурсов + комментарии
Python файлы: - handler.py → sql_runner.py (entrypoint: sql_runner.handle) - handler.py → notes_crud.py (entrypoint: notes_crud.handle) - handler.py → notes_list.py (entrypoint: notes_list.handle) TF ресурсы переименованы: - sless_function.notes → sless_function.notes_crud - sless_trigger.notes_http → sless_trigger.notes_crud_http - sless_job.create_table → sless_job.notes_table_init - sless_job.create_index → sless_job.notes_index_init - archive_file.notes → archive_file.notes_crud_zip - archive_file.sql_runner → archive_file.sql_runner_zip - archive_file.notes_list → archive_file.notes_list_zip Добавлены подробные комментарии во все .tf файлы
This commit is contained in:
@@ -1,18 +1,27 @@
|
||||
# 2025-06-05
|
||||
# notes-list.tf — функция для получения всех записей из таблицы notes.
|
||||
# GET или POST /fn/default/notes-list → JSON массив всех записей, сортировка по дате (новые первые).
|
||||
# 2026-03-09
|
||||
# notes-list.tf — функция для чтения всех заметок одним запросом.
|
||||
#
|
||||
# Отдельная от CRUD функция — «read-only» эндпоинт без роутинга.
|
||||
# Принимает GET или POST, параметры игнорирует.
|
||||
# Возвращает JSON-массив всех записей, сортировка: новые первые.
|
||||
#
|
||||
# Пример запроса:
|
||||
# curl https://sless-api.kube5s.ru/fn/default/notes-list
|
||||
|
||||
data "archive_file" "notes_list" {
|
||||
# Упаковка исходников notes_list.py в zip.
|
||||
data "archive_file" "notes_list_zip" {
|
||||
type = "zip"
|
||||
source_dir = "${path.module}/code/notes-list"
|
||||
output_path = "${path.module}/dist/notes-list.zip"
|
||||
}
|
||||
|
||||
# Read-only функция в кластере.
|
||||
# entrypoint = "notes_list.handle" → файл notes_list.py, функция handle().
|
||||
resource "sless_function" "notes_list" {
|
||||
namespace = "default"
|
||||
name = "notes-list"
|
||||
runtime = "python3.11"
|
||||
entrypoint = "handler.handle"
|
||||
entrypoint = "notes_list.handle"
|
||||
memory_mb = 128
|
||||
timeout_sec = 30
|
||||
|
||||
@@ -20,10 +29,12 @@ resource "sless_function" "notes_list" {
|
||||
PG_DSN = var.pg_dsn
|
||||
}
|
||||
|
||||
code_path = data.archive_file.notes_list.output_path
|
||||
code_hash = filesha256("${path.module}/code/notes-list/handler.py")
|
||||
code_path = data.archive_file.notes_list_zip.output_path
|
||||
code_hash = filesha256("${path.module}/code/notes-list/notes_list.py")
|
||||
}
|
||||
|
||||
# HTTP-триггер для read-only функции.
|
||||
# Создаёт Ingress, URL доступен в outputs.tf.
|
||||
resource "sless_trigger" "notes_list_http" {
|
||||
namespace = "default"
|
||||
name = "notes-list-http"
|
||||
|
||||
Reference in New Issue
Block a user