API Gateway Pattern: Managing APIs in Go
API Gateway is a single entry point for all clients. It routes requests to appropriate microservices, handles authentication, rate limiting, and aggregates responses. Let’s build one in Go.
Continue readingAPI Gateway is a single entry point for all clients. It routes requests to appropriate microservices, handles authentication, rate limiting, and aggregates responses. Let’s build one in Go.
Continue readingAPI Gateway - это единая точка входа для всех клиентов. Он маршрутизирует запросы к нужным микросервисам, обрабатывает аутентификацию, rate limiting и агрегирует ответы. Давайте построим его на Go.
Continue readingFactory Pattern solves one problem: how to create objects without being tied to concrete types. Instead of directly calling a constructor, use a factory function that decides which object to create.
Hey Gopher! 👋
Have you ever seen code like chan map[string]*map[int]chan struct{}? If yes, then you know what channel hell is.
This is a story about how we started simple, reached nightmare, and found an elegant solution. A real-time notification system that grew from 100 users to 100,000, and how we refactored the channel architecture.
Spoiler: we ended up replacing all this horror with 3 simple interfaces and typed channels 🚀
Continue readingHey tester! 👋
Are your tests slow, brittle, and dependent on external services? Every time the database is unavailable, half your tests fail?
Test Doubles are your salvation. Instead of real dependencies, use fakes: mocks, stubs, fakes.
Let’s break down how to properly isolate code for testing and write fast, reliable unit tests in Go 🚀
Continue readingIf you’re a Go developer used to automatic memory management, working with C might feel archaic. But understanding malloc/free is critical for CGO and low-level optimization.
A/B testing is everywhere: button colors, pricing, algorithms. But most implementations use frequentist statistics. Bayesian approach gives you probability of being better, not just “statistically significant”. Let’s implement it in Go.
Frequentist: “Is the difference statistically significant?”
Bayesian: “What’s the probability that B is better than A?”
type Variant struct {
Name string
Conversions int
Visitors int
}
func (v *Variant) Rate() float64 {
if v.Visitors == 0 {
return 0
}
return float64(v.Conversions) / float64(v.Visitors)
}
For conversion rates, we use Beta distribution:
Continue reading