ЛР 5 — асинхронная обработка и версии pipeline

This commit is contained in:
2026-11-16 02:38:13 +03:00
parent 276dbdad8a
commit 1f535f1b5b
163 changed files with 17194 additions and 24 deletions
+28
View File
@@ -0,0 +1,28 @@
global
log stdout format raw local0
stats socket ipv4@127.0.0.1:9999 level admin
defaults
mode http
log global
option httplog
timeout connect 2s
timeout client 30s
timeout server 30s
timeout http-request 10s
resolvers docker
nameserver docker 127.0.0.11:53
accepted_payload_size 8192
hold valid 1s
frontend api
bind *:8080
default_backend api_replicas
backend api_replicas
balance roundrobin
timeout check 3s
option httpchk GET /health/ready
http-check expect status 200
server-template api 4 api:8080 check inter 1s fall 2 rise 2 resolvers docker init-addr none
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<policymap>
<policy domain="resource" name="thread" value="1"/>
<policy domain="resource" name="memory" value="256MiB"/>
<policy domain="resource" name="map" value="256MiB"/>
<policy domain="resource" name="disk" value="512MiB"/>
<policy domain="resource" name="time" value="45"/>
<policy domain="resource" name="list-length" value="2"/>
<policy domain="delegate" rights="none" pattern="*"/>
<policy domain="filter" rights="none" pattern="*"/>
<policy domain="path" rights="none" pattern="@*"/>
<policy domain="module" rights="none" pattern="*"/>
<policy domain="module" rights="read | write" pattern="{JPEG,PNG,WEBP}"/>
<policy domain="coder" rights="none" pattern="*"/>
<policy domain="coder" rights="read | write" pattern="{JPEG,JPG,PNG,WEBP}"/>
</policymap>
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
set -eu
for name in rustfs_root_access_key rustfs_root_secret_key s3_access_key_id s3_secret_access_key; do
if [ ! -s "/run/secrets/$name" ]; then
echo "missing S3 secret: $name" >&2
exit 1
fi
done
root_key=$(cat /run/secrets/rustfs_root_access_key)
root_secret=$(cat /run/secrets/rustfs_root_secret_key)
app_key=$(cat /run/secrets/s3_access_key_id)
app_secret=$(cat /run/secrets/s3_secret_access_key)
if [ "$root_key" = "$app_key" ]; then
echo 'API and RustFS root access keys must differ' >&2
exit 1
fi
# These values become path and JSON fragments below.
case "$S3_BUCKET" in
messenger-attachments) ;;
*) echo 'unsupported S3_BUCKET in bootstrap' >&2; exit 1 ;;
esac
rc=/usr/bin/rc
policy=messenger-attachments-api-v1
"$rc" alias set root http://s3:9000 "$root_key" "$root_secret" \
--region "$S3_REGION" --bucket-lookup path >/dev/null
"$rc" bucket create "root/$S3_BUCKET" --ignore-existing
# A new bucket is private by default; this also removes a stale public policy.
"$rc" bucket anonymous set private "root/$S3_BUCKET"
cat > /tmp/api-policy.json <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket", "s3:GetBucketLocation"],
"Resource": "arn:aws:s3:::$S3_BUCKET"
},
{
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject"],
"Resource": "arn:aws:s3:::$S3_BUCKET/*"
}
]
}
EOF
if ! "$rc" admin policy info root/ "$policy" >/dev/null 2>&1; then
"$rc" admin policy create root/ "$policy" /tmp/api-policy.json
fi
if ! "$rc" admin user info root/ "$app_key" >/dev/null 2>&1; then
"$rc" admin user add root/ "$app_key" "$app_secret" >/dev/null
fi
"$rc" admin policy attach root/ "$policy" --user "$app_key" >/dev/null
"$rc" alias set app http://s3:9000 "$app_key" "$app_secret" \
--region "$S3_REGION" --bucket-lookup path >/dev/null
"$rc" bucket list "app/$S3_BUCKET" >/dev/null
echo "S3 bucket and API identity ready: $S3_BUCKET"