Skip to content
Open

Hw 01 #114

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target/
*.iws
*.iml
*.ipr
./http-client.env.json
/http-client.env.json

### NetBeans ###
/nbproject/private/
Expand All @@ -33,3 +33,7 @@ build/

### VS Code ###
.vscode/

grafana/
prometheus/
src/main/resources/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import org.slf4j.LoggerFactory
import ru.quipy.common.utils.SlidingWindowRateLimiter
import ru.quipy.core.EventSourcingService
import ru.quipy.payments.api.PaymentAggregate
import java.net.SocketTimeoutException
Expand Down Expand Up @@ -33,6 +34,7 @@ class PaymentExternalSystemAdapterImpl(
private val requestAverageProcessingTime = properties.averageProcessingTime
private val rateLimitPerSec = properties.rateLimitPerSec
private val parallelRequests = properties.parallelRequests
private val rateLimiter = SlidingWindowRateLimiter(rateLimitPerSec.toLong(), Duration.ofSeconds(1L))

private val client = OkHttpClient.Builder().build()

Expand All @@ -41,6 +43,8 @@ class PaymentExternalSystemAdapterImpl(

val transactionId = UUID.randomUUID()

rateLimiter.tickBlocking()

// Вне зависимости от исхода оплаты важно отметить что она была отправлена.
// Это требуется сделать ВО ВСЕХ СЛУЧАЯХ, поскольку эта информация используется сервисом тестирования.
paymentESService.update(paymentId) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ management.endpoints.web.exposure.include=info,health,prometheus,metrics

payment.service-name=${PAYMENT_SERVICE_NAME}
payment.token=${PAYMENT_TOKEN}
payment.accounts=${PAYMENT_ACCOUNTS:acc-12,acc-20}
payment.accounts=${PAYMENT_ACCOUNTS:acc-3}
payment.hostPort=${PAYMENT_HOST:localhost}:${PAYMENT_PORT:1234}
5 changes: 2 additions & 3 deletions test-local-run.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ Content-Type: application/json
{
"serviceName": "{{serviceName}}",
"token": "{{token}}",
"ratePerSecond": 1,
"testCount": 100,
"processingTimeMillis": 80000
"ratePerSecond": 11,
"testCount": 1200
}

### Stop running test to save time and resources
Expand Down
9 changes: 4 additions & 5 deletions test-on-prem-run.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ Content-Type: application/json
{
"serviceName": "{{serviceName}}",
"token": "{{token}}",
"branch": "main",
"accounts": "acc-12,acc-20",
"ratePerSecond": 2,
"testCount": 10,
"processingTimeMillis": 80000,
"branch": "hw-01",
"accounts": "acc-3",
"ratePerSecond": 11,
"testCount": 1200,
"onPremises": true
}

Expand Down