commonv1

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

This package provides the live/streaming client implementation for the Deepgram API

Index

Constants

View Source
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

View Source
const (
	PackageVersion string = "v1.0"
)

Variables

View Source
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

type RESTClient struct {
	*restv1.Client
}

*************************** 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.

func (*RESTClient) SetupRequest added in v1.6.0

func (c *RESTClient) SetupRequest(ctx context.Context, method, uri string, body io.Reader) (*http.Request, error)

SetupRequest prepares and returns a new HTTP request with common headers set.

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

gocritic:ignore

func (*WSClient) AttemptReconnect added in v1.6.0

func (c *WSClient) AttemptReconnect(ctx context.Context, retries int64) bool

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

func (c *WSClient) Connect() bool

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

func (c *WSClient) WriteBinary(byData []byte) error

WriteBinary writes binary data to the websocket server

func (*WSClient) WriteJSON added in v1.6.0

func (c *WSClient) WriteJSON(payload interface{}) error

WriteJSON writes a JSON control payload to the websocket server. These are control messages for managing the live transcription session on the Deepgram server.

Directories

Path Synopsis
This package defines interfaces for the live API
This package defines interfaces for the live API

Jump to

Keyboard shortcuts

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