Reference library

Microservices patterns

Service boundaries, discovery, inter-service calls, and decomposition patterns.

2 matches
Microservices patterns easy

How to mock a SPIFFE workload identity in Python

Generate a mock SPIFFE ID and token for a workload using a trust domain, namespace, and service account.

spiffe identity microservices
Python
import hashlib
import json
from dataclasses import dataclass, asdict


@dataclass
class SPIFFEIdentity:
    trust_domain: str
    namespace: str
    service_account: str

    @property
    def id(self) -> str:
        return f"spiffe://{self.trust_domain}/ns/{self.namespace}/sa/{self.service_account}"


def mock_workl…
13 0 Open
Microservices patterns medium

Zero Trust Service Auth Mock in Python

A simple HMAC-based token issuance and validation mock that enforces zero trust between microservices.

microservices authentication hmac
Python
import hmac
import hashlib
import json
import time

class ZeroTrustAuth:
    def __init__(self, secret_key):
        self.secret_key = secret_key
        self.service_tokens = {}

    def issue_token(self, service_name, ttl=300):
        payload = {
            "service": service_name,
            "issued_at": int(tim…
10 0 Open

Browse by section

Each section groups closely related Python snippets.

Microservices patterns — Python code examples

What you will find here

This page collects microservices patterns snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.