Documentation
¶
Overview ¶
Package http provides a TenantLister that pulls tenant IDs from a control-plane API conforming to the go-bricks pre-defined contract.
Contract (responses use the standard go-bricks APIResponse envelope):
GET <base>/tenants?limit=<int>&cursor=<opaque>
200 OK
{
"data": { "tenants": [ {"id": "..."}, ... ], "next_cursor": "..." },
"meta": { "timestamp": "...", "traceId": "..." }
}
4xx/5xx
{ "error": { "code": "...", "message": "..." }, "meta": { ... } }
next_cursor empty/absent ends the iteration.
Index ¶
Constants ¶
const DefaultPageLimit = 100
DefaultPageLimit is the default page size requested from the control-plane.
const DefaultTimeout = 30 * time.Second
DefaultTimeout is applied to the underlying *http.Client when none is supplied.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContractError ¶
ContractError is returned when the control-plane responds with a non-2xx status. It exposes the envelope's error fields for diagnostics.
func (*ContractError) Error ¶
func (e *ContractError) Error() string
type Options ¶
type Options struct {
// BearerToken is sent in the Authorization header when non-empty.
BearerToken string
// Client overrides the default HTTP client. When nil, a client with a
// DefaultTimeout is used.
Client *stdhttp.Client
// PageLimit is sent as the ?limit= query parameter on each request.
// Servers may cap this. When 0 or negative, DefaultPageLimit is used.
PageLimit int
}
Options configures TenantSource.
type TenantSource ¶
type TenantSource struct {
// contains filtered or unexported fields
}
TenantSource implements migration.TenantLister against an HTTP control-plane API.
func New ¶
func New(baseURL string, opts Options) (*TenantSource, error)
New constructs a TenantSource. baseURL must be parseable; the /tenants path is appended automatically.
func (*TenantSource) ListTenants ¶
func (s *TenantSource) ListTenants(ctx context.Context) ([]string, error)
ListTenants walks all pages of the contract endpoint and returns the union of tenant IDs.