Documentation ¶
Overview ¶
client is a package that implements a set of functions for connecting to the AWS secure tunneling service.
Index ¶
- type AWSClient
- type AWSClientOptions
- type AWSMessageListener
- type MockAWSMessageListener
- func (mock *MockAWSMessageListener) OnData(message *aws.Message) error
- func (mock *MockAWSMessageListener) OnServiceIDs(message *aws.Message) error
- func (mock *MockAWSMessageListener) OnSessionReset(message *aws.Message)
- func (mock *MockAWSMessageListener) OnStreamReset(message *aws.Message)
- func (mock *MockAWSMessageListener) OnStreamStart(message *aws.Message) error
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSClient ¶
type AWSClient interface { // Run keep websocket connection to secure tunneling service. // If the connection is successful, execute the following processing. // - Periodically send a ping frame to the service. // - Keep reading messages from the service and fire event handlers associated with AWSClientOptions.MessageListeners. // This method is a blocking method. // And this medhod does not return control to the caller until the following phenomenons occur. // - Caller context is done. // - http response status code is 400-499, when connecting to the service. // - Tunnel is closed. Run(ctx context.Context) error // SendStreamStart send StreamStart message to the service. // This method must be executed after Run() method. SendStreamStart(streamID int32, serviceID string) error // SendStreamReset send StreamReset message to the service. // This method must be executed after Run() method. SendStreamReset(streamID int32, serviceID string) error // SendData send Data message to the service. // This method must be executed after Run() method. SendData(streamID int32, serviceID string, data []byte) error }
AWSClient is an interface, for the purpose of connectiong secure tunneling service.
func NewAWSClient ¶
func NewAWSClient(options AWSClientOptions) (AWSClient, error)
NewAWSClient returns a instance which implements AWSClient.
type AWSClientOptions ¶
type AWSClientOptions struct { // Mode represents local proxy mode. Mode aws.Mode // Endpoint represents service endpoint. Endpoint *url.URL // Token represents token in the return value of AWS OpenTunnel WebAPI. Token string // TLSConfig If you want to customize tls.Config, set the value. Otherwise it sets null. TLSConfig *tls.Config // DialTimeout sets the timeout value when connecting to the service. DialTimeout time.Duration // ReconnectInterval represents the interval when reconnecting. ReconnectInterval time.Duration // PingInterval represents the interval when sending ping. PingInterval time.Duration // MessageListeners represents instances which implement AWSMessageListener interface. MessageListeners []AWSMessageListener // ConnectHandlers are event handlers to be fired // when the connection to the service is successful. // This event handlers also are fired on reconnection. // TODO: think arguments. ConnectHandlers []func() }
AWSClientOptions is options of AWSClient.
type AWSMessageListener ¶
type AWSMessageListener interface { // OnStreamStart is an event handler that fires when a StreamStart message is received. // See: https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/v2.1.0/V2WebSocketProtocolGuide.md#streamstart OnStreamStart(message *aws.Message) error // OnStreamReset is an event handler that fires when a StreamReset message is received. // This method may be executed multiple times with the same stream ID. // See: https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/v2.1.0/V2WebSocketProtocolGuide.md#streamreset OnStreamReset(message *aws.Message) // OnSessionReset is an event handler that fires when a SessionReset message is received. // See: https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/v2.1.0/V2WebSocketProtocolGuide.md#sessionreset OnSessionReset(message *aws.Message) // OnData is an event handler that fires when a Data message is received. // See: https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/v2.1.0/V2WebSocketProtocolGuide.md#data OnData(message *aws.Message) error // OnServiceIDs is an event handler that fires when a ServiceIDs message is received. // Note: // The server will also send a ServiceIDs message when reconnecting. // That is, this method will also be executed when reconnecting. // See: https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/v2.1.0/V2WebSocketProtocolGuide.md#serviceids OnServiceIDs(message *aws.Message) error }
AWSMessageListener is an interface representing event handlers to be fired when localproxy received message from secure tunneling service. AWSClient generates one goroutine for each StreamID to process the message.
type MockAWSMessageListener ¶
type MockAWSMessageListener struct { ChStreamStartArg chan *aws.Message MockOnStreamStart func(message *aws.Message) error ChStreamResetArg chan *aws.Message MockOnStreamReset func(message *aws.Message) ChSessionResetArg chan *aws.Message MockOnSessionReset func(message *aws.Message) ChDataArg chan *aws.Message MockOnData func(message *aws.Message) error ChServiceIDsArg chan *aws.Message MockServiceIDs func(message *aws.Message) error }
func NewMockAWSMessageListener ¶
func NewMockAWSMessageListener() *MockAWSMessageListener
func (*MockAWSMessageListener) OnData ¶
func (mock *MockAWSMessageListener) OnData(message *aws.Message) error
func (*MockAWSMessageListener) OnServiceIDs ¶
func (mock *MockAWSMessageListener) OnServiceIDs(message *aws.Message) error
func (*MockAWSMessageListener) OnSessionReset ¶
func (mock *MockAWSMessageListener) OnSessionReset(message *aws.Message)
func (*MockAWSMessageListener) OnStreamReset ¶
func (mock *MockAWSMessageListener) OnStreamReset(message *aws.Message)
func (*MockAWSMessageListener) OnStreamStart ¶
func (mock *MockAWSMessageListener) OnStreamStart(message *aws.Message) error
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is a structure that has one channel and manages one goroutine. You can write function to the channel using Exec(). The function is executed sequentially by the internal goroutine. This structure cannot be reused.
func (*Worker) Run ¶
Run is a method that behaves like Start(). This medhod does not return control to the caller until the following phenomenons occur.
- caller context is done.
- Stop() method.