Documentation
¶
Index ¶
- type BridgeConnectionInfo
- type Client
- func (c *Client) ClientURL() string
- func (c *Client) Close()
- func (c *Client) Connect() error
- func (c *Client) ConnectionInfo() BridgeConnectionInfo
- func (c *Client) ExpiresAt() time.Time
- func (c *Client) IsExpired() bool
- func (c *Client) Refresh() error
- func (c *Client) Reply(replyId string, status int, headers map[string]string, reader io.Reader) error
- func (c *Client) StreamURL() string
- func (c *Client) WebsocketURL() string
- type Handler
- type HandlerCallback
- func (h *HandlerCallback) OnClose(client *Client, id string)
- func (h *HandlerCallback) OnConnect(client *Client)
- func (h *HandlerCallback) OnData(client *Client, id string, data []byte)
- func (h *HandlerCallback) OnDisconnect(client *Client)
- func (h *HandlerCallback) OnError(client *Client, err error)
- func (h *HandlerCallback) OnHeader(client *Client, id string, headers map[string]string)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BridgeConnectionInfo ¶ added in v1.0.40
type BridgeConnectionInfo struct {
ExpiresAt *time.Time `json:"expires_at"`
WebsocketURL string `json:"websocket_url"`
StreamURL string `json:"stream_url"`
ClientURL string `json:"client_url"`
RepliesURL string `json:"replies_url"`
RefreshURL string `json:"refresh_url"`
}
func (*BridgeConnectionInfo) IsExpired ¶ added in v1.0.40
func (b *BridgeConnectionInfo) IsExpired() bool
IsExpired returns true if the connection has expired
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ClientURL ¶ added in v1.0.40
ClientURL returns the emphemeral client URL of the bridge connection
func (*Client) Close ¶
func (c *Client) Close()
Close closes the bridge client and disconnects from the bridge server
func (*Client) ConnectionInfo ¶ added in v1.0.40
func (c *Client) ConnectionInfo() BridgeConnectionInfo
ConnectionInfo returns the connection info for the bridge connection
func (*Client) Reply ¶
func (c *Client) Reply(replyId string, status int, headers map[string]string, reader io.Reader) error
Reply sends a reply to the incoming request
func (*Client) StreamURL ¶ added in v1.0.40
StreamURL returns the stream URL of the bridge connection
func (*Client) WebsocketURL ¶ added in v1.0.40
WebsocketURL returns the websocket URL of the bridge connection
type Handler ¶
type Handler interface {
// OnConnect is called when the bridge client is connected to the bridge server
OnConnect(client *Client)
// OnDisconnect is called when the bridge client is disconnected from the bridge server
OnDisconnect(client *Client)
// OnHeader is called when a header is received from the bridge. this will only be called once before any data is sent.
OnHeader(client *Client, id string, headers map[string]string)
// OnData is called when a data is received from the bridge. this will be called multiple times if the data is large.
OnData(client *Client, id string, data []byte)
// OnClose is called when the bridge request is completed and no more data will be sent
OnClose(client *Client, id string)
// OnError is called when an error occurs at any point in the bridge client
OnError(client *Client, err error)
}
Handler is an interface that defines the callback methods for a bridge handler to implement
type HandlerCallback ¶
type HandlerCallback struct {
OnConnectFunc func(client *Client)
OnDisconnectFunc func(client *Client)
OnHeaderFunc func(client *Client, id string, headers map[string]string)
OnDataFunc func(client *Client, id string, data []byte)
OnCloseFunc func(client *Client, id string)
OnErrorFunc func(client *Client, err error)
}
HandlerCallback is a struct that implements the BridgeHandler interface
func (*HandlerCallback) OnClose ¶
func (h *HandlerCallback) OnClose(client *Client, id string)
func (*HandlerCallback) OnConnect ¶
func (h *HandlerCallback) OnConnect(client *Client)
func (*HandlerCallback) OnData ¶
func (h *HandlerCallback) OnData(client *Client, id string, data []byte)
func (*HandlerCallback) OnDisconnect ¶ added in v1.0.40
func (h *HandlerCallback) OnDisconnect(client *Client)
func (*HandlerCallback) OnError ¶
func (h *HandlerCallback) OnError(client *Client, err error)
type Options ¶
type Options struct {
// Context is the context for the bridge client (optional)
Context context.Context
// Logger is the logger for the bridge client (optional)
Logger logger.Logger
// URL is the URL of the bridge (optional)
URL string
// APIKey is the API key for the bridge (optional, will use AGENTUITY_API_KEY environment variable if not set)
APIKey string
// Handler is the handler for the bridge client (required)
Handler Handler
// ConnectionInfo is the connection info for the bridge client (optional) which can be used to pre-populate the connection info
ConnectionInfo *BridgeConnectionInfo
}
Click to show internal directories.
Click to hide internal directories.