Documentation
¶
Index ¶
- Variables
- type AuthConfig
- type Client
- type Manager
- func (m *Manager) Call(ctx context.Context, serviceID string, req Request, response interface{}) error
- func (m *Manager) GetClient(id string) (*Client, error)
- func (m *Manager) GetClientByURL(rawURL string) (*Client, string, error)
- func (m *Manager) ListServices() []string
- func (m *Manager) LoadServices(filePath string) error
- type Option
- type Registry
- type RemoteError
- type Request
- type RetryConfig
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRequestFailed = errors.New("remote: request failed") ErrTimeout = errors.New("remote: request timed out") ErrBadRequest = errors.New("remote: invalid request") ErrNotFound = errors.New("remote: resource not found") )
View Source
var DefaultRetryConfig = RetryConfig{ MaxRetries: 3, InitialBackoff: 500 * time.Millisecond, MaxBackoff: 10 * time.Second, RetryableStatus: []int{ http.StatusTooManyRequests, http.StatusInternalServerError, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout, }, }
DefaultRetryConfig provides a sensible default for most services.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Type string `json:"type"` // "api_key", "oauth2", "bearer"
Options json.RawMessage `json:"options"`
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) GetClientByURL ¶
func (*Manager) ListServices ¶
func (*Manager) LoadServices ¶
type Option ¶
type Option func(*Client)
func WithAuthenticator ¶
func WithAuthenticator(a auth.Authenticator) Option
func WithTimeout ¶
type Registry ¶
type Registry struct {
Version string `json:"version"`
Services []ServiceConfig `json:"services"`
}
type RemoteError ¶
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
func (*RemoteError) Unwrap ¶
func (e *RemoteError) Unwrap() error
type Request ¶
type Request struct {
Method string
Path string
Query url.Values
Body any
Headers map[string]string
Retry *RetryConfig // If nil, no retries will be performed
}
Request bundles all the caller-provided parts of an outbound call.
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int // Maximum number of retries (0 = no retries)
InitialBackoff time.Duration // Time to wait before the first retry
MaxBackoff time.Duration // Maximum wait time between retries
RetryableStatus []int // HTTP status codes that should trigger a retry
}
RetryConfig defines the strategy for retrying failed requests.
type ServiceConfig ¶
type ServiceConfig struct {
ID string `json:"id"`
URL string `json:"url"`
Timeout string `json:"timeout"`
Auth *AuthConfig `json:"auth,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.