Documentation
¶
Overview ¶
Package provider provides generic multi-provider client management.
The Client[T] type provides common functionality for managing multiple providers with primary/fallback selection. It is designed to be embedded in domain-specific clients (tts.Client, stt.Client, realtime.Client).
Example usage:
type MyClient struct {
*provider.Client[MyProvider]
hook MyHook
}
func NewMyClient(providers ...MyProvider) *MyClient {
return &MyClient{
Client: provider.NewClient(providers...),
}
}
Index ¶
- type Client
- func (c *Client[T]) All() map[string]T
- func (c *Client[T]) FallbackNames() []string
- func (c *Client[T]) Fallbacks() []T
- func (c *Client[T]) Primary() (T, bool)
- func (c *Client[T]) PrimaryName() string
- func (c *Client[T]) Provider(name string) (T, bool)
- func (c *Client[T]) SetFallbacks(names ...string)
- func (c *Client[T]) SetPrimary(name string)
- type Named
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client[T Named] struct { // contains filtered or unexported fields }
Client provides multi-provider management with fallback support. It is designed to be embedded in domain-specific client types.
func NewClient ¶
NewClient creates a client with the specified providers. The first provider is set as primary.
func (*Client[T]) FallbackNames ¶
FallbackNames returns the names of fallback providers in order.
func (*Client[T]) Fallbacks ¶
func (c *Client[T]) Fallbacks() []T
Fallbacks returns all fallback providers in order.
func (*Client[T]) PrimaryName ¶
PrimaryName returns the name of the primary provider.
func (*Client[T]) SetFallbacks ¶
SetFallbacks sets the fallback provider order.
func (*Client[T]) SetPrimary ¶
SetPrimary sets the primary provider by name.