http-client

java
package com.example.github;

import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;

Declarative Typed HTTP Client With Retrofit and an OkHttp Auth Interceptor

retrofit okhttp http-client
by codesnips 3 tabs
rust
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::Mutex;
use tokio::time::sleep;

#[derive(Debug)]

Rate-Limiting Outbound HTTP with a Token Bucket in Rust (Tokio)

rust tokio rate-limiting
by codesnips 3 tabs
java
package com.example.rates.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.web.client.RestTemplate;

Retrying a Flaky External API with Spring Retry @Retryable and @Recover Fallback

spring-boot spring-retry resilience
by codesnips 4 tabs
php
<?php

namespace App\Message;

final class SyncCustomerMessage
{

Retrying Flaky HTTP Calls with a Symfony Messenger Retry Strategy and Failure Handler

symfony messenger retry
by codesnips 3 tabs
java
public class ProductAggregator implements AutoCloseable {

    private final RemoteServices services;
    private final ExecutorService pool = Executors.newFixedThreadPool(8);

    public ProductAggregator(RemoteServices services) {

Coordinate Parallel Remote Lookups With CompletableFuture in Java

java completablefuture concurrency
by codesnips 3 tabs
typescript
export interface Cursor {
  createdAt: string;
  id: string;
}

export function encodeCursor(c: Cursor): string {

Cursor Pagination for a REST List Endpoint with a Typed Fetch Client

typescript express rest
by codesnips 3 tabs
java
package com.example.paging;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

Consume a Paginated REST API by Following Next-Page Links in Java

java pagination rest-api
by codesnips 3 tabs
php
<?php

namespace App\Services\RateLimit;

use Illuminate\Support\Facades\Redis;

Rate-Limited HTTP Client Wrapper With Redis Token Bucket and a Queued Dispatcher

laravel redis rate-limiting
by codesnips 4 tabs
typescript
export class TimeoutError extends Error {
  constructor(public readonly ms: number) {
    super(`Request timed out after ${ms}ms`);
    this.name = "TimeoutError";
  }
}

HTTP client timeout with AbortController (fetch)

fetch abortcontroller timeout
by codesnips 3 tabs
go
package quotes

import (
	"context"
	"encoding/json"
	"fmt"

Fan-In Parallel API Calls With a Bounded Worker Pool and Context Cancellation

go concurrency goroutines
by codesnips 3 tabs
php
<?php

use Illuminate\Support\Facades\Http;

// Retry with exponential backoff
$response = Http::retry(3, 100, function ($exception, $request) {

Laravel HTTP client for API consumption

laravel http-client api
by Carlos Mendez 3 tabs
go
package authtransport

import (
	"errors"
	"net/http"
)

Injecting Auth Headers via a Custom http.RoundTripper Decorator in Go

go http middleware
by codesnips 3 tabs