Documentation ¶
Overview ¶
This package provides the live/streaming client implementation for the Deepgram API
Index ¶
- Constants
- Variables
- type RESTClient
- type WSClient
- func (c *WSClient) AttemptReconnect(ctx context.Context, retries int64) bool
- func (c *WSClient) AttemptReconnectWithCancel(ctx context.Context, ctxCancel context.CancelFunc, retries int64) bool
- func (c *WSClient) Connect() bool
- func (c *WSClient) ConnectWithCancel(ctx context.Context, ctxCancel context.CancelFunc, retryCnt int) bool
- func (c *WSClient) Stop()
- func (c *WSClient) WriteBinary(byData []byte) error
- func (c *WSClient) WriteJSON(payload interface{}) error
Constants ¶
const ( DefaultConnectRetry int64 = 3 ChunkSize = 1024 * 2 TerminationSleep = 100 * time.Millisecond // socket errors FatalReadSocketErr string = "read: can't assign requested address" FatalWriteSocketErr string = "write: broken pipe" UseOfClosedSocket string = "use of closed network connection" UnknownDeepgramErr string = "unknown deepgram error" // socket successful close error SuccessfulSocketErr string = "close 1000" )
external constants
const (
PackageVersion string = "v1.0"
)
Variables ¶
var ( // ErrInvalidInput required input was not found ErrInvalidInput = errors.New("required input was not found") // ErrInvalidConnection connection is not valid ErrInvalidConnection = errors.New("connection is not valid") // ErrFatalPanicRecovered fatal panic recovered ErrFatalPanicRecovered = errors.New("fatal panic - attempt to recover") )
errors
Functions ¶
This section is empty.
Types ¶
type RESTClient ¶
*************************** Common REST Client *************************** RESTClient implements an extensible REST client
func NewREST ¶ added in v1.6.0
func NewREST(apiKey string, options *interfaces.ClientOptions) *RESTClient
func (*RESTClient) HandleResponse ¶ added in v1.6.0
func (c *RESTClient) HandleResponse(res *http.Response, keys []string, resBody interface{}) (map[string]string, error)
HandleResponse processes the HTTP response for both streaming and URL-based API requests.
type WSClient ¶ added in v1.6.0
type WSClient struct {
// contains filtered or unexported fields
}
*************************** Common WS Client *************************** WSClient is a struct representing the websocket client connection
func NewWS ¶ added in v1.6.0
func NewWS(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, options *clientinterfaces.ClientOptions, processMessages *commonv1interfaces.WebSocketHandler, router *commonv1interfaces.Router) *WSClient
gocritic:ignore
func (*WSClient) AttemptReconnect ¶ added in v1.6.0
AttemptReconnect performs a reconnect after failing retries
func (*WSClient) AttemptReconnectWithCancel ¶ added in v1.6.0
func (c *WSClient) AttemptReconnectWithCancel(ctx context.Context, ctxCancel context.CancelFunc, retries int64) bool
AttemptReconnect performs a reconnect after failing retries and providing a cancel function
func (*WSClient) Connect ¶ added in v1.6.0
Connect performs a websocket connection with "DefaultConnectRetry" number of retries.
func (*WSClient) ConnectWithCancel ¶ added in v1.6.0
func (c *WSClient) ConnectWithCancel(ctx context.Context, ctxCancel context.CancelFunc, retryCnt int) bool
ConnectWithCancel performs a websocket connection with specified number of retries and providing a cancel function to stop the connection
func (*WSClient) Stop ¶ added in v1.6.0
func (c *WSClient) Stop()
Stop will send close message and shutdown websocket connection
func (*WSClient) WriteBinary ¶ added in v1.6.0
WriteBinary writes binary data to the websocket server
Directories ¶
Path | Synopsis |
---|---|
This package defines interfaces for the live API
|
This package defines interfaces for the live API |