provider

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 1 Imported by: 0

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

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

func NewClient[T Named](providers ...T) *Client[T]

NewClient creates a client with the specified providers. The first provider is set as primary.

func (*Client[T]) All

func (c *Client[T]) All() map[string]T

All returns all providers.

func (*Client[T]) FallbackNames

func (c *Client[T]) FallbackNames() []string

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]) Primary

func (c *Client[T]) Primary() (T, bool)

Primary returns the primary provider.

func (*Client[T]) PrimaryName

func (c *Client[T]) PrimaryName() string

PrimaryName returns the name of the primary provider.

func (*Client[T]) Provider

func (c *Client[T]) Provider(name string) (T, bool)

Provider returns a specific provider by name.

func (*Client[T]) SetFallbacks

func (c *Client[T]) SetFallbacks(names ...string)

SetFallbacks sets the fallback provider order.

func (*Client[T]) SetPrimary

func (c *Client[T]) SetPrimary(name string)

SetPrimary sets the primary provider by name.

type Named

type Named interface {
	Name() string
}

Named is the interface that all providers must implement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL