Documentation
¶
Overview ¶
Package regionpeers lets a single-region service handler serve extra regions by lazily building one sibling handler per non-home region.
Index ¶
Constants ¶
const (
// MaxPeers bounds siblings per Set; AWS has well under 64 regions.
MaxPeers = 64
)
Variables ¶
This section is empty.
Functions ¶
func Backend ¶
Backend returns the backend serving region from backendFor (a handler's BackendFor method) as T; ok is false when it is not a T.
func ValidRegion ¶
ValidRegion reports whether region looks like an AWS region code.
Types ¶
type Set ¶
type Set[T any] struct { // contains filtered or unexported fields }
Set holds the lazily built per-region siblings of one home handler. A nil *Set is valid and means the service serves only its home region.
func New ¶
New returns a Set whose siblings are made by build. Requests for home or an empty region are never routed to a sibling.
func (*Set[T]) All ¶
func (s *Set[T]) All() []*T
All returns the siblings built so far, ordered by region, without removing them.
func (*Set[T]) Drain ¶
func (s *Set[T]) Drain() []*T
Drain removes and returns every sibling so the caller can reset or close them.
func (*Set[T]) Get ¶
Get returns region's sibling, creating it on first use; nil means the home handler serves (home region, malformed region, or MaxPeers reached), so garbage regions cannot grow siblings.