### Install Go Dependencies Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Install project dependencies using Go modules. Ensure you have Go installed and configured. ```bash go mod tidy ``` -------------------------------- ### Start Dashboard Server Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Starts the dashboard server to visualize load test results. Use --no-open to prevent automatic browser launch. ```bash python3 tests/loadtest/tools/dashboard.py ``` ```bash python3 tests/loadtest/tools/dashboard.py --no-open ``` -------------------------------- ### Manual Queue Benchmark Start Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Manually starts the queue benchmark tool. Requires Redis DSN and queue prefixes. Use -wait to block until the queue is drained. ```bash go run ./tests/loadtest/tools/queue_benchmark.go \ -redis-dsn "$BLNK_REDIS_DNS" \ -queue-prefixes "new:transaction_,hot_" \ -wait \ -out tests/loadtest/queue-summary.json ``` -------------------------------- ### Start Local Services with Docker Compose Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Start PostgreSQL and Redis services using Docker Compose. These services are required for local development and testing. ```bash docker compose up -d postgres redis ``` -------------------------------- ### Start Load Test Dashboard Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/tools/README.md Starts a local web server for the load test dashboard. It automatically scans for k6 summary files, NDJSON exports, and CSV files. ```bash python3 tests/loadtest/tools/dashboard.py ``` -------------------------------- ### Install act for Local CI Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Install the 'act' tool on macOS using Homebrew. This tool allows running GitHub Actions workflows locally. ```bash brew install act # macOS ``` -------------------------------- ### Create Blnk Event with Bloc Mapper Source: https://github.com/blnkfinance/blnk/wiki/Events-&-Mappers Construct a Blnk event payload using a pre-defined mapper to translate external transaction data. This example shows how to trigger a 'transaction.new' event with Bloc's transaction details. ```json { "mapper_id": "map_3db6f05a-8f5a-43e4-a91c-b5a6c5e7d5a1", "drcr": "Credit", "balance_id": "bln_c1750613-b4b0-4cde-9793-459165a8715f", "data": { "event": "transaction.new", "data": { "amount": 30000, "currency": "NGN", "reference": "1jhbs3ozmen0k7y5e333feeme3rrr33ewwedffdew", "source": "Collection Account", "status": "successful" } } } ``` -------------------------------- ### Run Tests with Make Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Execute tests using the 'make test' command. This is an alternative way to run the test suite. ```bash make test ``` -------------------------------- ### Build Blnk Binary Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Build the Blnk executable binary. This command compiles the Go source files into an executable. ```bash go build -o blnk ./cmd/*.go ``` -------------------------------- ### Run Database Migrations Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Apply database migrations to set up the schema. This command ensures the database is in the correct state for development. ```bash ./blnk migrate up ``` -------------------------------- ### Create Balance Monitor Configuration Source: https://github.com/blnkfinance/blnk/wiki/Ledgers-&-Balances Configure a balance monitor by specifying the balance ID and the condition to trigger an alert. This is useful for setting up automated monitoring of specific financial thresholds. ```json { "balance_id": "bln_c1750613-b4b0-4cde-9793-459165a8715f", "condition": { "field": "debit_balance", "operator": ">", "value": 100000 } } ``` -------------------------------- ### Clone Blnk Repository Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Clone the Blnk repository to your local machine. This is the first step in setting up the development environment. ```bash git clone https://github.com/blnkfinance/blnk.git cd blnk ``` -------------------------------- ### Manual k6 Run for Hot Source Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Manually runs a k6 load test scenario targeting a hot source. Configure environment variables for URL, scenario, duration, rate, VUS, and sharding. ```bash k6 run \ --out json=tests/loadtest/run.ndjson \ -e SUMMARY_OUT=tests/loadtest/summary.json \ -e URL='http://localhost:5001/transactions' \ -e SCENARIO='hot_source' \ -e DURATION='30s' \ -e RATE='300' \ -e VUS='200' \ -e MAX_VUS='800' \ -e SOURCE_BUCKETS='1' \ tests/loadtest/script.js ``` -------------------------------- ### Run Load Test Case Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Executes a predefined load test case using a helper script. This script manages both the queue benchmark and k6 load test execution. ```bash bash tests/loadtest/run_case.sh hot-to-cold-no-shard ``` ```bash bash tests/loadtest/run_case.sh cold-to-hot-no-shard ``` ```bash bash tests/loadtest/run_case.sh hot-to-cold-shard ``` ```bash bash tests/loadtest/run_case.sh cold-to-hot-shard ``` ```bash bash tests/loadtest/run_case.sh hot-to-cold-no-shard hot ``` -------------------------------- ### Generate Queue Benchmark JSON Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/tools/README.md Generates a k6-shaped summary JSON from Asynq queue stats for temporary benchmarking. Use -queue-prefix to specify queue names and -wait to pause until backlog appears. ```bash go run ./tests/loadtest/tools/queue_benchmark.go \ -queue-prefix new:transaction_ \ -wait \ -out tests/loadtest/queue-summary.json ``` ```bash go run ./tests/loadtest/tools/queue_benchmark.go \ -queues new:transaction_18 \ -out tests/loadtest/queue-summary.json ``` ```bash go run ./tests/loadtest/tools/queue_benchmark.go \ -redis-dsn "$BLNK_REDIS_DNS" \ -queue-prefix new:transaction_ \ -wait \ -out tests/loadtest/queue-summary.json ``` -------------------------------- ### Manual k6 Run for Hot Destination Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Manually runs a k6 load test scenario targeting a hot destination. Configure environment variables for URL, scenario, duration, rate, VUS, and sharding. ```bash k6 run \ --out json=tests/loadtest/run.ndjson \ -e SUMMARY_OUT=tests/loadtest/summary.json \ -e URL='http://localhost:5001/transactions' \ -e SCENARIO='hot_destination' \ -e DURATION='30s' \ -e RATE='300' \ -e VUS='200' \ -e MAX_VUS='800' \ -e DESTINATION_BUCKETS='1' \ tests/loadtest/script.js ``` -------------------------------- ### Configure Load Test Dashboard Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/tools/README.md Optional flags for the dashboard script. Use --no-open to prevent automatic browser opening, --port to specify a port, and --root to set the scan directory. ```bash python3 tests/loadtest/tools/dashboard.py --no-open ``` ```bash python3 tests/loadtest/tools/dashboard.py --port 9000 ``` ```bash python3 tests/loadtest/tools/dashboard.py --root tests/loadtest ``` -------------------------------- ### Manual k6 Run with Increased Sharding Source: https://github.com/blnkfinance/blnk/blob/main/tests/loadtest/README.md Reruns a k6 load test with increased sharding for either hot source or hot destination scenarios. Adjust SOURCE_BUCKETS or DESTINATION_BUCKETS accordingly. ```bash k6 run \ --out json=tests/loadtest/run.ndjson \ -e SUMMARY_OUT=tests/loadtest/summary.json \ -e URL='http://localhost:5001/transactions' \ -e SCENARIO='hot_source' \ -e DURATION='30s' \ -e RATE='300' \ -e VUS='200' \ -e MAX_VUS='800' \ -e SOURCE_BUCKETS='8' \ tests/loadtest/script.js ``` -------------------------------- ### Run Fast Local Tests Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Execute tests locally with the '-short' flag, which skips long-running tests. This is useful for quick feedback during development. ```bash go test -short ./... ``` -------------------------------- ### Run Full Local Tests Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Execute all tests locally without any flags. This provides a comprehensive test coverage check. ```bash go test ./... ``` -------------------------------- ### Run CI Workflow Locally with act Source: https://github.com/blnkfinance/blnk/blob/main/CONTRIBUTING.md Execute the GitHub Actions CI pipeline locally using 'act'. Ensure Docker is running before executing this command. ```bash act -W .github/workflows/go.yml ``` -------------------------------- ### Create Blnk Account JSON Structure Source: https://github.com/blnkfinance/blnk/wiki/Accounts Use this JSON structure to create a new account in Blnk. Ensure 'identity_id' and 'balance_id' are valid Blnk resource identifiers. ```json { "bank_name": "Blnk bank", "number": "30888888832", "identity_id": "idt_0501db5c-baf9-4be1-a931-f4bae7f3a41d", "balance_id": "bln_c1750613-b4b0-4cde-9793-459165a8715f" } ``` -------------------------------- ### Calculate Rejection Rate by Reason Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md Query Prometheus to determine the rate of rejected transactions, broken down by rejection reason, over a 5-minute window. ```promql # Rejection rate by reason rate(blnk_transaction_rejected_total[5m]) ``` -------------------------------- ### Configure Prometheus Scrape Job Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md Configure your Prometheus instance to scrape Blnk's metrics endpoint, including bearer token authentication if server security is enabled. ```yaml scrape_configs: - job_name: 'blnk-server' authorization: type: Bearer credentials: '' static_configs: - targets: ['server:5001'] ``` -------------------------------- ### Calculate Transaction Throughput Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md Query Prometheus to calculate the rate of transactions per second over a 5-minute window. ```promql # Transaction throughput (per second, 5 minute window) rate(blnk_transaction_total[5m]) ``` -------------------------------- ### Monitor Queue Enqueue Rate Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md This Prometheus query shows the rate at which items are being enqueued into the system's queues over a 5-minute window. ```PromQL rate(blnk_queue_enqueued_total[5m]) ``` -------------------------------- ### Create Balance Linked to Identity Source: https://github.com/blnkfinance/blnk/wiki/Identity Use this JSON payload to create a new balance and associate it with an existing identity by providing the `identity_id`. ```json { "ledger_id": "ldg_db5eabf0-4152-47cf-8353-d1729a491962", "identity_id": "idt_0501db5c-baf9-4be1-a931-f4bae7f3a41d", "currency": "NGN" } ``` -------------------------------- ### Create Bloc Transaction Mapper Source: https://github.com/blnkfinance/blnk/wiki/Events-&-Mappers Define a JSON structure to map Bloc's transaction data fields to Blnk's standardized format. This mapper specifies how to extract amount, reference, and currency from Bloc's payload. ```json { "name": "Bloc transaction webhook mapping", "mapping_instruction": { "amount": "{data.amount}", "reference": "{data.reference}", "currency": "{data.currency}" } } ``` -------------------------------- ### Configure External Account Number Generation Source: https://github.com/blnkfinance/blnk/wiki/Accounts Include this JSON configuration in your Blnk settings to enable automated account number generation from an external HTTP service. ```json "account_number_generation": { "http_service": { "url": "https://example.com/generate_account_number", "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "Bearer some_auth_token" } } } ``` -------------------------------- ### Calculate P99 Transaction Latency Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md Use this Prometheus query to calculate the 99th percentile of transaction durations over a 5-minute window. ```PromQL histogram_quantile(0.99, rate(blnk_transaction_duration_seconds_bucket[5m])) ``` -------------------------------- ### Schedule Transaction Payload Source: https://github.com/blnkfinance/blnk/wiki/Transactions Include the 'scheduled_for' parameter with a timestamp in ISO 8601 format to schedule a transaction for future execution. Ensure all other required transaction fields are present. ```json { "amount": 10000, "tag": "Commission Earned", "reference": "ref", "drcr": "Credit", "currency": "NGN", "ledger_id": "ldg_3fa24854-211f-4248-9611-a7744aeaefcd", "balance_id": "bln_0abdbf91-d4b7-4917-bfdc-7fdf1680a3ca", "scheduled_for": "2023-10-08T19:48:00Z" } ``` -------------------------------- ### External Account Generation Service Response Format Source: https://github.com/blnkfinance/blnk/wiki/Accounts The external service used for account number generation must return JSON in this format, providing the generated account number and its associated bank name. ```json { "account_number": "", "bank_name": "" } ``` -------------------------------- ### Calculate Hot Lane Traffic Ratio Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md This Prometheus query calculates the ratio of traffic routed to the 'hot' lane compared to the total traffic routed. It helps understand the proportion of traffic handled by the specialized hot lane. ```PromQL blnk_hotpairs_lane_routed_total{lane="hot"} / blnk_hotpairs_lane_routed_total ``` -------------------------------- ### Transaction Normalization Function Source: https://github.com/blnkfinance/blnk/wiki/Fraud-Detection This pseudo-code function normalizes a given value against a specified minimum and maximum, scaling it to a 0-1 range. It's used to standardize financial parameters for fraud score computation. ```pseudo function normalize(value, min=0, max) { return (value - min) / (max - min) } ``` -------------------------------- ### Blnk Transaction Record Source: https://github.com/blnkfinance/blnk/wiki/Events-&-Mappers The resulting Blnk transaction record after processing an event and applying a mapper. This shows the standardized format for a queued transaction, including amounts, currency, and status. ```json { "id": "txn_9da2b9bc-a0f4-4832-bb2a-5a493eedb5b3", "tag": "", "reference": "1jhbs3ozmen0k7y5e333feeme3rrr33ewwedffdew", "amount": 30000, "currency": "NGN", "drcr": "Credit", "status": "QUEUED", "ledger_id": "ldg_db5eabf0-4152-47cf-8353-d1729a491962", "balance_id": "bln_c1750613-b4b0-4cde-9793-459165a8715f", "credit_balance_before": 246000, "debit_balance_before": 0, "credit_balance_after": 276000, "debit_balance_after": 0, "balance_before": 246000, "balance_after": 276000, "created_at": "2023-10-19T07:59:22.052869+01:00", "scheduled_for": "0001-01-01T00:00:00Z" } ``` -------------------------------- ### Calculate Worker Retry Rate Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md This Prometheus query measures the rate of worker retries over a 5-minute window, indicating the frequency of task failures and subsequent retries. ```PromQL rate(blnk_worker_retries_total[5m]) ``` -------------------------------- ### Calculate Batch Coalescing Success Rate Source: https://github.com/blnkfinance/blnk/blob/main/docs/metrics.md This Prometheus query determines the success rate of batch coalescing operations by dividing the count of successful batches by the total number of batches processed. ```PromQL blnk_transaction_batch_total{result="success"} / blnk_transaction_batch_total ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.