Skip to content

Commit

Permalink
#139 Add rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman committed Jun 14, 2024
1 parent 3051d43 commit 33328fa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ru.vityaman.lms.botalka.core.publication.telegram

import kotlinx.coroutines.delay
import ru.vityaman.lms.botalka.core.external.telegram.TelegramBot
import ru.vityaman.lms.botalka.core.external.telegram.TelegramChat
import ru.vityaman.lms.botalka.core.external.telegram.TelegramMessage
import ru.vityaman.lms.botalka.core.model.Homework
import ru.vityaman.lms.botalka.core.publication.PublicationConsumer
import kotlin.time.Duration.Companion.seconds

class TelegramPublicationConsumer(
private val telegram: TelegramBot,
Expand All @@ -21,5 +23,6 @@ class TelegramPublicationConsumer(
append("Id: ${value.id.number}\n")
}
telegram.send(adminChat, TelegramMessage(text))
delay(1.seconds)
}
}
4 changes: 2 additions & 2 deletions infra/fuzzing/custom/homeworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MOMENT="$2"
echo "[fuzz] Got access token: '$TOKEN'"
echo "[fuzz] Got moment: '$MOMENT'"

for _ in $(seq 1 32); do
for _ in $(seq 1 128); do
curl -X 'POST' \
'http://localhost:8080/api/v1/homework' \
-H 'accept: application/json' \
Expand All @@ -20,5 +20,5 @@ for _ in $(seq 1 32); do
\"max_score\": 500,
\"publication_moment\": \"$MOMENT\",
\"deadline_moment\": \"2026-07-11T12:00:00Z\"
}"
}" &
done
2 changes: 1 addition & 1 deletion infra/kafka/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ topic() {
$KAFKA_TOPICS \
--bootstrap-server "$HOST:$PORT" \
--create --if-not-exists --topic "$NAME" \
--replication-factor 1 --partitions 1
--replication-factor 1 --partitions 2
}

topic "publication"
Expand Down

0 comments on commit 33328fa

Please sign in to comment.