fan-out

python
import time
from dataclasses import dataclass
from typing import Optional

import requests

Bounded Concurrent HTTP Fan-Out With ThreadPoolExecutor and Retries

python concurrency threadpool
by codesnips 2 tabs
go
package pipeline

import "context"

func generate(ctx context.Context, nums ...int) <-chan int {
	out := make(chan int)

Fan-Out/Fan-In Pipeline With Channels and Context Cancellation in Go

go concurrency channels
by codesnips 3 tabs
php
<?php

namespace App\Providers;

use App\Events\OrderPlaced;
use App\Listeners\DecrementInventory;

Fan Out an Order Placed Domain Event to Multiple Queued Laravel Listeners

laravel events queues
by codesnips 4 tabs
ruby
module BoundedFanOut
  Result = Struct.new(:value, :error) do
    def ok?
      error.nil?
    end
  end

Parallelize Independent External Calls (in a bounded way)

concurrency threads http
by codesnips 3 tabs
ruby
class ShippedEmailJob
  include Sidekiq::Job
  sidekiq_options queue: :mailers, retry: 5

  def perform(order_id)
    order = Order.find_by(id: order_id)

Fan Out Notifications to Email and SMS Using an ActiveRecord Observer

rails activerecord observer
by codesnips 3 tabs
go
package fetch

import (
	"context"
	"net/http"

Bounded Fan-Out With Worker Pool, errgroup, and Result Collection in Go

go concurrency goroutines
by codesnips 3 tabs
go
package hub

type Hub struct {
	subscribers map[*Subscriber]struct{}
	broadcast   chan []byte
	register    chan registration

Concurrent Fan-Out Event Hub With Non-Blocking Broadcast in Go

go concurrency channels
by codesnips 3 tabs