Documentation ¶
Index ¶
- Constants
- Variables
- func ContextSessionID(ctx context.Context) (string, bool)
- func GetDocumentFactory(t MediaType) (func() Document, error)
- func NewCtxConn(conn net.Conn, readTimeout time.Duration, writeTimeout time.Duration) *ctxConn
- func NewEnvelopeID() string
- func RegisterDocumentFactory(f func() Document)
- type Authentication
- type AuthenticationResult
- type AuthenticationScheme
- type Authenticator
- type BoundListener
- type Client
- func (c *Client) Close() error
- func (c *Client) Establish(ctx context.Context) error
- func (c *Client) ProcessCommand(ctx context.Context, cmd *RequestCommand) (*ResponseCommand, error)
- func (c *Client) SendMessage(ctx context.Context, msg *Message) error
- func (c *Client) SendNotification(ctx context.Context, not *Notification) error
- func (c *Client) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
- type ClientBuilder
- func (b *ClientBuilder) AutoReplyPings() *ClientBuilder
- func (b *ClientBuilder) Build() *Client
- func (b *ClientBuilder) ChannelBufferSize(bufferSize int) *ClientBuilder
- func (b *ClientBuilder) Compression(c SessionCompression) *ClientBuilder
- func (b *ClientBuilder) Domain(domain string) *ClientBuilder
- func (b *ClientBuilder) Encryption(e SessionEncryption) *ClientBuilder
- func (b *ClientBuilder) ExternalAuthentication(token, issuer string) *ClientBuilder
- func (b *ClientBuilder) GuestAuthentication() *ClientBuilder
- func (b *ClientBuilder) Instance(instance string) *ClientBuilder
- func (b *ClientBuilder) KeyAuthentication(key string) *ClientBuilder
- func (b *ClientBuilder) MessageHandler(handler MessageHandler) *ClientBuilder
- func (b *ClientBuilder) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) MessagesHandlerFunc(f MessageHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) Name(name string) *ClientBuilder
- func (b *ClientBuilder) NotificationHandler(handler NotificationHandler) *ClientBuilder
- func (b *ClientBuilder) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) NotificationsHandlerFunc(f NotificationHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) PlainAuthentication(password string) *ClientBuilder
- func (b *ClientBuilder) RequestCommandHandler(handler RequestCommandHandler) *ClientBuilder
- func (b *ClientBuilder) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) RequestCommandsHandlerFunc(f RequestCommandHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) ResponseCommandHandler(handler ResponseCommandHandler) *ClientBuilder
- func (b *ClientBuilder) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) ResponseCommandsHandlerFunc(f ResponseCommandHandlerFunc) *ClientBuilder
- func (b *ClientBuilder) TransportAuthentication() *ClientBuilder
- func (b *ClientBuilder) UseInProcess(addr InProcessAddr, bufferSize int) *ClientBuilder
- func (b *ClientBuilder) UseTCP(addr net.Addr, config *TCPConfig) *ClientBuilder
- func (b *ClientBuilder) UseWebsocket(urlStr string, requestHeader http.Header, tls *tls.Config) *ClientBuilder
- type ClientChannel
- func (c ClientChannel) Close() error
- func (c *ClientChannel) EstablishSession(ctx context.Context, compSelector CompressionSelector, ...) (*Session, error)
- func (c ClientChannel) Established() bool
- func (c *ClientChannel) FinishSession(ctx context.Context) (*Session, error)
- func (c ClientChannel) ID() string
- func (c ClientChannel) LocalNode() Node
- func (c ClientChannel) MsgChan() <-chan *Message
- func (c ClientChannel) NotChan() <-chan *Notification
- func (c ClientChannel) ProcessCommand(ctx context.Context, reqCmd *RequestCommand) (*ResponseCommand, error)
- func (c ClientChannel) RcvDone() <-chan struct{}
- func (c ClientChannel) RemoteNode() Node
- func (c ClientChannel) ReqCmdChan() <-chan *RequestCommand
- func (c ClientChannel) RespCmdChan() <-chan *ResponseCommand
- func (c ClientChannel) SendMessage(ctx context.Context, msg *Message) error
- func (c ClientChannel) SendNotification(ctx context.Context, not *Notification) error
- func (c ClientChannel) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
- func (c ClientChannel) SendResponseCommand(ctx context.Context, cmd *ResponseCommand) error
- func (c ClientChannel) State() SessionState
- type ClientConfig
- type Command
- type CommandMethod
- type CommandProcessor
- type CommandStatus
- type CompressionSelector
- type Document
- type DocumentCollection
- type DocumentContainer
- type DomainRole
- type EncryptionSelector
- type Envelope
- func (env *Envelope) Sender() Node
- func (env *Envelope) SetFrom(from Node) *Envelope
- func (env *Envelope) SetFromString(s string) *Envelope
- func (env *Envelope) SetID(id string) *Envelope
- func (env *Envelope) SetMetadataKeyValue(key string, value string) *Envelope
- func (env *Envelope) SetNewEnvelopeID() *Envelope
- func (env *Envelope) SetPP(pp Node) *Envelope
- func (env *Envelope) SetPPString(s string) *Envelope
- func (env *Envelope) SetTo(to Node) *Envelope
- func (env *Envelope) SetToString(s string) *Envelope
- type EnvelopeMux
- func (m *EnvelopeMux) ListenClient(ctx context.Context, c *ClientChannel) error
- func (m *EnvelopeMux) ListenServer(ctx context.Context, c *ServerChannel) error
- func (m *EnvelopeMux) MessageHandler(handler MessageHandler)
- func (m *EnvelopeMux) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc)
- func (m *EnvelopeMux) NotificationHandler(handler NotificationHandler)
- func (m *EnvelopeMux) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc)
- func (m *EnvelopeMux) RequestCommandHandler(handler RequestCommandHandler)
- func (m *EnvelopeMux) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc)
- func (m *EnvelopeMux) ResponseCommandHandler(handler ResponseCommandHandler)
- func (m *EnvelopeMux) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc)
- type ExternalAuthentication
- type ExternalAuthenticator
- type GuestAuthentication
- type Identity
- type InProcessAddr
- type JsonDocument
- type KeyAuthentication
- type KeyAuthenticator
- type MediaType
- type Message
- type MessageHandler
- type MessageHandlerFunc
- type MessagePredicate
- type MessageReceiver
- type MessageSender
- type Node
- type Notification
- type NotificationEvent
- type NotificationHandler
- type NotificationHandlerFunc
- type NotificationPredicate
- type NotificationReceiver
- type NotificationSender
- type Ping
- type PlainAuthentication
- type PlainAuthenticator
- type Reason
- type Receiver
- type RequestCommand
- func (cmd *RequestCommand) FailureResponse(reason *Reason) *ResponseCommand
- func (cmd *RequestCommand) MarshalJSON() ([]byte, error)
- func (cmd *RequestCommand) SetURI(uri *URI) *RequestCommand
- func (cmd *RequestCommand) SetURIString(s string) *RequestCommand
- func (cmd *RequestCommand) SuccessResponse() *ResponseCommand
- func (cmd *RequestCommand) SuccessResponseWithResource(resource Document) *ResponseCommand
- func (cmd *RequestCommand) UnmarshalJSON(b []byte) error
- type RequestCommandHandler
- type RequestCommandHandlerFunc
- type RequestCommandPredicate
- type RequestCommandReceiver
- type RequestCommandSender
- type ResponseCommand
- type ResponseCommandHandler
- type ResponseCommandHandlerFunc
- type ResponseCommandPredicate
- type ResponseCommandReceiver
- type ResponseCommandSender
- type Sender
- type Server
- type ServerBuilder
- func (b *ServerBuilder) AutoReplyPings() *ServerBuilder
- func (b *ServerBuilder) Build() *Server
- func (b *ServerBuilder) ChannelBufferSize(bufferSize int) *ServerBuilder
- func (b *ServerBuilder) CompressionOptions(compOpts ...SessionCompression) *ServerBuilder
- func (b *ServerBuilder) Domain(domain string) *ServerBuilder
- func (b *ServerBuilder) EnableExternalAuthentication(a ExternalAuthenticator) *ServerBuilder
- func (b *ServerBuilder) EnableGuestAuthentication() *ServerBuilder
- func (b *ServerBuilder) EnableKeyAuthentication(a KeyAuthenticator) *ServerBuilder
- func (b *ServerBuilder) EnablePlainAuthentication(a PlainAuthenticator) *ServerBuilder
- func (b *ServerBuilder) EnableTransportAuthentication() *ServerBuilder
- func (b *ServerBuilder) EncryptionOptions(encryptOpts ...SessionEncryption) *ServerBuilder
- func (b *ServerBuilder) Established(established func(sessionID string, c *ServerChannel)) *ServerBuilder
- func (b *ServerBuilder) Finished(finished func(sessionID string)) *ServerBuilder
- func (b *ServerBuilder) Instance(instance string) *ServerBuilder
- func (b *ServerBuilder) ListenInProcess(addr InProcessAddr) *ServerBuilder
- func (b *ServerBuilder) ListenTCP(addr *net.TCPAddr, config *TCPConfig) *ServerBuilder
- func (b *ServerBuilder) ListenWebsocket(addr *net.TCPAddr, config *WebsocketConfig) *ServerBuilder
- func (b *ServerBuilder) MessageHandler(handler MessageHandler) *ServerBuilder
- func (b *ServerBuilder) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) MessagesHandlerFunc(f MessageHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) Name(name string) *ServerBuilder
- func (b *ServerBuilder) NotificationHandler(handler NotificationHandler) *ServerBuilder
- func (b *ServerBuilder) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) NotificationsHandlerFunc(f NotificationHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) Register(...) *ServerBuilder
- func (b *ServerBuilder) RequestCommandHandler(handler RequestCommandHandler) *ServerBuilder
- func (b *ServerBuilder) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) RequestCommandsHandlerFunc(f RequestCommandHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) ResponseCommandHandler(handler ResponseCommandHandler) *ServerBuilder
- func (b *ServerBuilder) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc) *ServerBuilder
- func (b *ServerBuilder) ResponseCommandsHandlerFunc(f ResponseCommandHandlerFunc) *ServerBuilder
- type ServerChannel
- func (c ServerChannel) Close() error
- func (c *ServerChannel) EstablishSession(ctx context.Context, compOpts []SessionCompression, ...) error
- func (c ServerChannel) Established() bool
- func (c *ServerChannel) FailSession(ctx context.Context, reason *Reason) error
- func (c *ServerChannel) FinishSession(ctx context.Context) error
- func (c ServerChannel) ID() string
- func (c ServerChannel) LocalNode() Node
- func (c ServerChannel) MsgChan() <-chan *Message
- func (c ServerChannel) NotChan() <-chan *Notification
- func (c ServerChannel) ProcessCommand(ctx context.Context, reqCmd *RequestCommand) (*ResponseCommand, error)
- func (c ServerChannel) RcvDone() <-chan struct{}
- func (c ServerChannel) RemoteNode() Node
- func (c ServerChannel) ReqCmdChan() <-chan *RequestCommand
- func (c ServerChannel) RespCmdChan() <-chan *ResponseCommand
- func (c ServerChannel) SendMessage(ctx context.Context, msg *Message) error
- func (c ServerChannel) SendNotification(ctx context.Context, not *Notification) error
- func (c ServerChannel) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
- func (c ServerChannel) SendResponseCommand(ctx context.Context, cmd *ResponseCommand) error
- func (c ServerChannel) State() SessionState
- type ServerConfig
- type Session
- type SessionCompression
- type SessionEncryption
- type SessionState
- type StdoutTraceWriter
- type TCPConfig
- type TextDocument
- type TraceWriter
- type Transport
- type TransportAuthentication
- type TransportListener
- type URI
- type WebsocketConfig
Constants ¶
const ( // CommandMethodGet Get an existing value of a resource. CommandMethodGet = CommandMethod("get") // CommandMethodSet Create or updates the value of a resource. CommandMethodSet = CommandMethod("set") // CommandMethodDelete Delete a value of the resource or the resource itself. CommandMethodDelete = CommandMethod("delete") // CommandMethodSubscribe Subscribe To a resource, allowing the originator To be notified when the // value of the resource changes in the destination. CommandMethodSubscribe = CommandMethod("subscribe") // CommandMethodUnsubscribe Unsubscribe To the resource, signaling To the destination that the // originator do not want To receive further notifications about the resource. CommandMethodUnsubscribe = CommandMethod("unsubscribe") // CommandMethodObserve Notify the destination about a change in a resource value of the sender. // If the resource value is absent, it represents that the resource in the specified URI was deleted in the originator. // This method can be one way and the destination may not send a response for it. // Because of that, a command envelope with this method may not have an ID. CommandMethodObserve = CommandMethod("observe") // CommandMethodMerge Merge a resource document with an existing one. If the resource doesn't exist, it is created. CommandMethodMerge = CommandMethod("merge") )
const ( CommandStatusSuccess = CommandStatus("success") CommandStatusFailure = CommandStatus("failure") )
const ( MediaTypeText = "text" MediaTypeApplication = "application" MediaTypeImage = "image" MediaTypeAudio = "audio" MediaTypeVideo = "video" )
const ( // NotificationEventAccepted The message was received and accepted by the server. // This event is similar To 'received' but is emitted by an intermediate node (hop) and not by the message's final destination. NotificationEventAccepted = NotificationEvent("accepted") // NotificationEventDispatched The message was dispatched to the destination by the server. // This event is similar To the 'consumed' but is emitted by an intermediate node (hop) and not by the message's final destination. NotificationEventDispatched = NotificationEvent("dispatched") // NotificationEventReceived The node has received the message. NotificationEventReceived = NotificationEvent("received") // NotificationEventConsumed The node has consumed the Content of the message. NotificationEventConsumed = NotificationEvent("consumed") // NotificationEventFailed A problem occurred during the processing of the message. // In this case, the reason property of the notification should be present. NotificationEventFailed = NotificationEvent("failed") )
const ( DomainRoleUnknown = DomainRole("unknown") // The identity is not part of the domain. DomainRoleMember = DomainRole("member") // The identity is a member of the domain. DomainRoleAuthority = DomainRole("authority") // The identity is an authority of the domain. DomainRoleRootAuthority = DomainRole("rootAuthority") // The identity is an authority of the domain and its subdomains. )
const ( // SessionStateNew indicates that the session is new and doesn't exist an established context. // It is sent by a client node To start a session with a server. SessionStateNew = SessionState("new") // SessionStateNegotiating indicates that the server and the client are negotiating the session options, // like cryptography and compression. // The server sends To the client the options (if available) and // the client chooses the desired options. If there's no options // (for instance, if the connection is already encrypted or the // transport protocol doesn't support these options), the server // SHOULD skip the negotiation. SessionStateNegotiating = SessionState("negotiating") // SessionStateAuthenticating indicates that the session is being authenticated. The server sends To // the client the available authentication schemes list and // the client must choose one and send the specific authentication // data. The authentication can occur in multiple round trips, // according To the selected schema. SessionStateAuthenticating = SessionState("authenticating") // SessionStateEstablished indicates that the session is active, and it is possible To send and receive // messages and commands. The server sends this state // after the session was authenticated. SessionStateEstablished = SessionState("established") // SessionStateFinishing indicates that the client node is requesting to the server to finish the session. SessionStateFinishing = SessionState("finishing") // SessionStateFinished indicates that the session was gracefully finished by the server. SessionStateFinished = SessionState("finished") // SessionStateFailed indicates that a problem occurred while the session was established, under // negotiation or authentication, and it was closed by the server. // In this case, the property reason MUST be present to provide // more details about the problem. SessionStateFailed = SessionState("failed") )
const ( // SessionEncryptionNone The session is not encrypted. SessionEncryptionNone = SessionEncryption("none") // SessionEncryptionTLS The session is encrypted by TLS (Transport Layer Security). SessionEncryptionTLS = SessionEncryption("tls") )
const ( // SessionCompressionNone The session is not compressed. SessionCompressionNone = SessionCompression("none") // SessionCompressionGzip The session is using the GZip algorithm for compression. SessionCompressionGzip = SessionCompression("gzip") )
const ( // AuthenticationSchemeGuest The server doesn't require a client credential, and provides a temporary // identity to the node. Some restriction may apply To guest sessions, like // the inability of sending some commands or other nodes may want To block // messages originated by guest identities. AuthenticationSchemeGuest = AuthenticationScheme("guest") // AuthenticationSchemePlain Username and password authentication. AuthenticationSchemePlain = AuthenticationScheme("plain") // AuthenticationSchemeKey Key authentication. AuthenticationSchemeKey = AuthenticationScheme("key") // AuthenticationSchemeTransport Transport layer authentication. AuthenticationSchemeTransport = AuthenticationScheme("transport") // AuthenticationSchemeExternal Third-party authentication. AuthenticationSchemeExternal = AuthenticationScheme("external") )
const DefaultReadLimit int64 = 8192 * 1024
const InProcessNetwork = "in.process"
const URISchemeLime = "lime"
Variables ¶
var ErrServerClosed = errors.New("lime: Server closed")
ErrServerClosed is returned by the Server's ListenAndServe, method after a call to Close.
Functions ¶
func ContextSessionID ¶
ContextSessionID gets the session id from the context.
func GetDocumentFactory ¶
func NewCtxConn ¶ added in v0.0.8
func NewEnvelopeID ¶ added in v0.0.30
func NewEnvelopeID() string
NewEnvelopeID generates a new unique envelope ID.
func RegisterDocumentFactory ¶
func RegisterDocumentFactory(f func() Document)
RegisterDocumentFactory allow the registration of new Document types, which allow these types to be discovered for the envelope deserialization process.
Types ¶
type Authentication ¶
type Authentication interface {
GetAuthenticationScheme() AuthenticationScheme
}
Authentication defines a session authentications scheme container
type AuthenticationResult ¶
type AuthenticationResult struct { Role DomainRole RoundTrip Authentication }
AuthenticationResult represents the result of a session authentication.
func AuthorityAuthenticationResult ¶ added in v0.0.15
func AuthorityAuthenticationResult() *AuthenticationResult
func MemberAuthenticationResult ¶ added in v0.0.15
func MemberAuthenticationResult() *AuthenticationResult
func RootAuthorityAuthenticationResult ¶ added in v0.0.15
func RootAuthorityAuthenticationResult() *AuthenticationResult
func UnknownAuthenticationResult ¶ added in v0.0.15
func UnknownAuthenticationResult() *AuthenticationResult
type AuthenticationScheme ¶
type AuthenticationScheme string
AuthenticationScheme Defines the valid authentication schemes values.
type Authenticator ¶
type Authenticator func(schemes []AuthenticationScheme, roundTrip Authentication) Authentication
var GuestAuthenticator Authenticator = func(schemes []AuthenticationScheme, roundTrip Authentication) Authentication { return &GuestAuthentication{} }
var TransportAuthenticator Authenticator = func(schemes []AuthenticationScheme, roundTrip Authentication) Authentication { return &TransportAuthentication{} }
type BoundListener ¶ added in v0.0.15
type BoundListener struct { Listener TransportListener Addr net.Addr }
BoundListener represents a pair of a TransportListener and a net.Addr values.
func NewBoundListener ¶ added in v0.0.15
func NewBoundListener(listener TransportListener, addr net.Addr) BoundListener
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allow the creation of a Lime connection with a server. The connection lifetime is handled automatically, with automatic reconnections in case of unrequested disconnections. There are methods for sending messages, notifications and command. It also allows the definition of handles for receiving these envelopes from the remote party.
func NewClient ¶ added in v0.0.16
func NewClient(config *ClientConfig, mux *EnvelopeMux) *Client
NewClient creates a new instance of the Client type.
func (*Client) Close ¶ added in v0.0.16
Close stops the listener and finishes any established session with the server.
func (*Client) Establish ¶ added in v0.0.18
Establish forces the establishment of a session, in case of not being already established. It also awaits for any establishment operation that is in progress, returning only when it succeeds.
func (*Client) ProcessCommand ¶ added in v0.0.16
func (c *Client) ProcessCommand(ctx context.Context, cmd *RequestCommand) (*ResponseCommand, error)
ProcessCommand send a RequestCommand to the server and returns the corresponding ResponseCommand.
func (*Client) SendMessage ¶ added in v0.0.16
SendMessage asynchronously sends a Message to the server. The server may route the Message to another node, accordingly to the specified destination address. It may also send back one or more Notification envelopes, containing status about the Message.
func (*Client) SendNotification ¶ added in v0.0.16
func (c *Client) SendNotification(ctx context.Context, not *Notification) error
SendNotification asynchronously sends a Notification to the server. The server may route the Notification to another node, accordingly to the specified destination address.
func (*Client) SendRequestCommand ¶ added in v0.0.28
func (c *Client) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
SendRequestCommand asynchronously sends a RequestCommand to the server. The server may route the RequestCommand to another node, accordingly to the specified destination address. This method can be used for sending request and response commands, but in case of requests, it does not await for response. For receiving the response, the ProcessCommand method should be used.
type ClientBuilder ¶
type ClientBuilder struct {
// contains filtered or unexported fields
}
ClientBuilder is a helper for building instances of Client. Avoid instantiating it directly, use the NewClientBuilder() function instead.
func NewClientBuilder ¶
func NewClientBuilder() *ClientBuilder
NewClientBuilder creates a new ClientBuilder, which is a helper for building Client instances. It provides a fluent interface for convenience.
func (*ClientBuilder) AutoReplyPings ¶ added in v0.0.45
func (b *ClientBuilder) AutoReplyPings() *ClientBuilder
AutoReplyPings adds a RequestCommandHandler handler to automatically reply ping requests from the remote node.
func (*ClientBuilder) Build ¶
func (b *ClientBuilder) Build() *Client
Build creates a new instance of Client.
func (*ClientBuilder) ChannelBufferSize ¶ added in v0.0.16
func (b *ClientBuilder) ChannelBufferSize(bufferSize int) *ClientBuilder
ChannelBufferSize is the size of the internal envelope buffer used by the ClientChannel. Greater values may improve the performance, but will also increase the process memory usage.
func (*ClientBuilder) Compression ¶ added in v0.0.16
func (b *ClientBuilder) Compression(c SessionCompression) *ClientBuilder
Compression sets the compression to be used in the session negotiation.
func (*ClientBuilder) Domain ¶ added in v0.0.16
func (b *ClientBuilder) Domain(domain string) *ClientBuilder
Domain sets the client's node domain.
func (*ClientBuilder) Encryption ¶ added in v0.0.16
func (b *ClientBuilder) Encryption(e SessionEncryption) *ClientBuilder
Encryption sets the encryption to be used in the session negotiation.
func (*ClientBuilder) ExternalAuthentication ¶ added in v0.0.16
func (b *ClientBuilder) ExternalAuthentication(token, issuer string) *ClientBuilder
ExternalAuthentication enables the use of the external authentication during the session establishment with the server.
func (*ClientBuilder) GuestAuthentication ¶ added in v0.0.16
func (b *ClientBuilder) GuestAuthentication() *ClientBuilder
GuestAuthentication enables the use of the guest authentication scheme during the session establishment with the server.
func (*ClientBuilder) Instance ¶ added in v0.0.16
func (b *ClientBuilder) Instance(instance string) *ClientBuilder
Instance sets the client's node instance.
func (*ClientBuilder) KeyAuthentication ¶ added in v0.0.16
func (b *ClientBuilder) KeyAuthentication(key string) *ClientBuilder
KeyAuthentication enables the use of the key authentication during the session establishment with the server.
func (*ClientBuilder) MessageHandler ¶ added in v0.0.16
func (b *ClientBuilder) MessageHandler(handler MessageHandler) *ClientBuilder
MessageHandler allows the registration of a MessageHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) MessageHandlerFunc ¶ added in v0.0.16
func (b *ClientBuilder) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc) *ClientBuilder
MessageHandlerFunc allows the registration of a function for handling received messages that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) MessagesHandlerFunc ¶ added in v0.0.16
func (b *ClientBuilder) MessagesHandlerFunc(f MessageHandlerFunc) *ClientBuilder
MessagesHandlerFunc allows the registration of a function for handling all received messages. This handler should be the last one to be registered, since it will capture all messages received by the client.
func (*ClientBuilder) Name ¶ added in v0.0.16
func (b *ClientBuilder) Name(name string) *ClientBuilder
Name sets the client's node name.
func (*ClientBuilder) NotificationHandler ¶ added in v0.0.16
func (b *ClientBuilder) NotificationHandler(handler NotificationHandler) *ClientBuilder
NotificationHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) NotificationHandlerFunc ¶ added in v0.0.16
func (b *ClientBuilder) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc) *ClientBuilder
NotificationHandlerFunc allows the registration of a function for handling received notifications that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) NotificationsHandlerFunc ¶ added in v0.0.16
func (b *ClientBuilder) NotificationsHandlerFunc(f NotificationHandlerFunc) *ClientBuilder
NotificationsHandlerFunc allows the registration of a function for handling all received notifications. This handler should be the last one to be registered, since it will capture all notifications received by the client.
func (*ClientBuilder) PlainAuthentication ¶ added in v0.0.16
func (b *ClientBuilder) PlainAuthentication(password string) *ClientBuilder
PlainAuthentication enables the use of the password authentication during the session establishment with the server.
func (*ClientBuilder) RequestCommandHandler ¶ added in v0.0.28
func (b *ClientBuilder) RequestCommandHandler(handler RequestCommandHandler) *ClientBuilder
RequestCommandHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) RequestCommandHandlerFunc ¶ added in v0.0.28
func (b *ClientBuilder) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc) *ClientBuilder
RequestCommandHandlerFunc allows the registration of a function for handling received commands that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) RequestCommandsHandlerFunc ¶ added in v0.0.28
func (b *ClientBuilder) RequestCommandsHandlerFunc(f RequestCommandHandlerFunc) *ClientBuilder
RequestCommandsHandlerFunc allows the registration of a function for handling all received commands. This handler should be the last one to be registered, since it will capture all commands received by the client.
func (*ClientBuilder) ResponseCommandHandler ¶ added in v0.0.28
func (b *ClientBuilder) ResponseCommandHandler(handler ResponseCommandHandler) *ClientBuilder
ResponseCommandHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) ResponseCommandHandlerFunc ¶ added in v0.0.28
func (b *ClientBuilder) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc) *ClientBuilder
ResponseCommandHandlerFunc allows the registration of a function for handling received commands that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ClientBuilder) ResponseCommandsHandlerFunc ¶ added in v0.0.28
func (b *ClientBuilder) ResponseCommandsHandlerFunc(f ResponseCommandHandlerFunc) *ClientBuilder
ResponseCommandsHandlerFunc allows the registration of a function for handling all received commands. This handler should be the last one to be registered, since it will capture all commands received by the client.
func (*ClientBuilder) TransportAuthentication ¶ added in v0.0.16
func (b *ClientBuilder) TransportAuthentication() *ClientBuilder
TransportAuthentication enables the use of the transport authentication scheme during the session establishment with the server. Note that the transport that are being used to communicate with the server will be asked to present the credentials, and the form of passing the credentials may vary depending on the transport type. For instance, in TCP transport connections, the client certificate used during the mutual TLS negotiation is considered the credentials by the server.
func (*ClientBuilder) UseInProcess ¶ added in v0.0.16
func (b *ClientBuilder) UseInProcess(addr InProcessAddr, bufferSize int) *ClientBuilder
UseInProcess adds an in-process listener to the server, allowing receiving virtual connections from this transport.
func (*ClientBuilder) UseTCP ¶ added in v0.0.16
func (b *ClientBuilder) UseTCP(addr net.Addr, config *TCPConfig) *ClientBuilder
UseTCP adds a TCP listener to the server, allowing receiving connections from this transport.
func (*ClientBuilder) UseWebsocket ¶ added in v0.0.16
func (b *ClientBuilder) UseWebsocket(urlStr string, requestHeader http.Header, tls *tls.Config) *ClientBuilder
UseWebsocket adds a Websockets listener to the server, allowing receiving connections from this transport.
type ClientChannel ¶
type ClientChannel struct {
// contains filtered or unexported fields
}
ClientChannel implements the client-side communication channel in a Lime session.
func NewClientChannel ¶
func NewClientChannel(t Transport, bufferSize int) *ClientChannel
func (*ClientChannel) EstablishSession ¶
func (c *ClientChannel) EstablishSession( ctx context.Context, compSelector CompressionSelector, encryptSelector EncryptionSelector, identity Identity, authenticator Authenticator, instance string, ) (*Session, error)
EstablishSession performs the client session negotiation and authentication handshake.
func (ClientChannel) Established ¶
func (c ClientChannel) Established() bool
func (*ClientChannel) FinishSession ¶
func (c *ClientChannel) FinishSession(ctx context.Context) (*Session, error)
FinishSession performs the session finishing handshake.
func (ClientChannel) NotChan ¶
func (c ClientChannel) NotChan() <-chan *Notification
func (ClientChannel) ProcessCommand ¶
func (c ClientChannel) ProcessCommand(ctx context.Context, reqCmd *RequestCommand) (*ResponseCommand, error)
func (ClientChannel) RcvDone ¶ added in v0.0.19
func (c ClientChannel) RcvDone() <-chan struct{}
RcvDone signals when the channel receiver goroutine is done. This usually indicates that the session with the remote node was finished.
func (ClientChannel) RemoteNode ¶
func (c ClientChannel) RemoteNode() Node
func (ClientChannel) ReqCmdChan ¶ added in v0.0.28
func (c ClientChannel) ReqCmdChan() <-chan *RequestCommand
func (ClientChannel) RespCmdChan ¶ added in v0.0.28
func (c ClientChannel) RespCmdChan() <-chan *ResponseCommand
func (ClientChannel) SendMessage ¶
func (ClientChannel) SendNotification ¶
func (c ClientChannel) SendNotification(ctx context.Context, not *Notification) error
func (ClientChannel) SendRequestCommand ¶ added in v0.0.28
func (c ClientChannel) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
func (ClientChannel) SendResponseCommand ¶ added in v0.0.28
func (c ClientChannel) SendResponseCommand(ctx context.Context, cmd *ResponseCommand) error
func (ClientChannel) State ¶
func (c ClientChannel) State() SessionState
type ClientConfig ¶ added in v0.0.16
type ClientConfig struct { // Node represents the address that the client should use in the session negotiation. // Note that the server may not use/accept the provided instance value, and it may be changed during the authentication. Node Node // The size of the internal envelope buffer used by the ClientChannel. // Greater values may improve the performance, but will also increase the process memory usage. ChannelBufferSize int // NewTransport represents the factory for Transport instances. NewTransport func(ctx context.Context) (Transport, error) // CompSelector is called during the session negotiation, for selecting the SessionCompression to be used. CompSelector CompressionSelector // EncryptSelector is called during the session negotiation, for selecting the SessionEncryption to be used. EncryptSelector EncryptionSelector // Authenticator is called during the session authentication and allows the client to provide its credentials // during the process. Authenticator Authenticator }
ClientConfig defines the configurations for a Client instance.
func NewClientConfig ¶ added in v0.0.16
func NewClientConfig() *ClientConfig
NewClientConfig creates a new instance of ClientConfig with the default configuration values.
type Command ¶
type Command struct { Envelope Method CommandMethod // Method defines the action to be taken to the resource. Type *MediaType // Type defines MIME declaration of the resource type of the command. Resource Document // Resource defines the document that is subject of the command. }
Command is the base type for the RequestCommand and ResponseCommand types. It allows the manipulation of node resources, like server session parameters or information related to the network nodes.
func (*Command) SetMethod ¶ added in v0.0.34
func (cmd *Command) SetMethod(method CommandMethod) *Command
func (*Command) SetResource ¶
type CommandMethod ¶
type CommandMethod string
CommandMethod Defines methods for the manipulation of resources.
func (CommandMethod) MarshalText ¶
func (m CommandMethod) MarshalText() ([]byte, error)
func (*CommandMethod) UnmarshalText ¶
func (m *CommandMethod) UnmarshalText(text []byte) error
func (CommandMethod) Validate ¶ added in v0.0.5
func (m CommandMethod) Validate() error
type CommandProcessor ¶
type CommandProcessor interface {
ProcessCommand(ctx context.Context, cmd *RequestCommand) (*ResponseCommand, error)
}
type CommandStatus ¶
type CommandStatus string
type CompressionSelector ¶
type CompressionSelector func(options []SessionCompression) SessionCompression
CompressionSelector defines a function for selecting the compression for a session.
var NoneCompressionSelector CompressionSelector = func(options []SessionCompression) SessionCompression { return SessionCompressionNone }
type Document ¶
type Document interface { // MediaType gets the type of the media for the document. MediaType() MediaType }
Document defines an entity with a media type.
func UnmarshalDocument ¶
func UnmarshalDocument(d *json.RawMessage, t MediaType) (Document, error)
type DocumentCollection ¶
type DocumentCollection struct { // The total of items in the collection. // This value refers to the original source collection, // without any applied filter that may exist in the // items on this instance. Total int // The media type of all items of the collection. ItemType MediaType // The collection items. Items []Document }
DocumentCollection represents a collection of documents.
func NewDocumentCollection ¶
func NewDocumentCollection(items []Document, t MediaType) *DocumentCollection
func (*DocumentCollection) MarshalJSON ¶
func (d *DocumentCollection) MarshalJSON() ([]byte, error)
func (*DocumentCollection) MediaType ¶
func (d *DocumentCollection) MediaType() MediaType
func (*DocumentCollection) UnmarshalJSON ¶
func (d *DocumentCollection) UnmarshalJSON(b []byte) error
type DocumentContainer ¶
type DocumentContainer struct { // The media type of the contained document. Type MediaType // The contained document value. Value Document }
DocumentContainer represents a generic container for a document, providing a media type for the correct handling of its value by the nodes. This type can be used along with DocumentCollection to transport distinct document types in a single message.
func NewDocumentContainer ¶
func NewDocumentContainer(d Document) *DocumentContainer
func (*DocumentContainer) MarshalJSON ¶
func (d *DocumentContainer) MarshalJSON() ([]byte, error)
func (*DocumentContainer) MediaType ¶
func (d *DocumentContainer) MediaType() MediaType
func (*DocumentContainer) UnmarshalJSON ¶
func (d *DocumentContainer) UnmarshalJSON(b []byte) error
type EncryptionSelector ¶
type EncryptionSelector func(options []SessionEncryption) SessionEncryption
EncryptionSelector defines a function for selecting the encryption for a session.
var NoneEncryptionSelector EncryptionSelector = func(options []SessionEncryption) SessionEncryption { return SessionEncryptionNone }
var TLSEncryptionSelector EncryptionSelector = func(options []SessionEncryption) SessionEncryption { return SessionEncryptionTLS }
type Envelope ¶
type Envelope struct { // ID is the envelope identifier ID string // From is the identifier of the sender node of the envelope. // If a node receives an envelope without this value, it means that the envelope was originated by the remote party. From Node // PP is the delegation node. It's an acronym for 'per procurationem'. // Identifier of a delegate node (a node that received a permission To send on behalf of another). // Allows a node to send an envelope on behalf of another identity. PP Node // To is the identifier of the destination node of the envelope. // If a node receives an envelope without this value, it means that the envelope is addressed To itself. To Node // Metadata holds additional information to be delivered with the envelope. Metadata map[string]string }
Envelope is the base struct to all protocol envelopes.
func (*Envelope) SetFromString ¶ added in v0.0.34
func (*Envelope) SetMetadataKeyValue ¶ added in v0.0.30
func (*Envelope) SetNewEnvelopeID ¶ added in v0.0.34
func (*Envelope) SetPPString ¶ added in v0.0.34
func (*Envelope) SetToString ¶ added in v0.0.30
type EnvelopeMux ¶
type EnvelopeMux struct {
// contains filtered or unexported fields
}
func (*EnvelopeMux) ListenClient ¶
func (m *EnvelopeMux) ListenClient(ctx context.Context, c *ClientChannel) error
func (*EnvelopeMux) ListenServer ¶
func (m *EnvelopeMux) ListenServer(ctx context.Context, c *ServerChannel) error
func (*EnvelopeMux) MessageHandler ¶
func (m *EnvelopeMux) MessageHandler(handler MessageHandler)
func (*EnvelopeMux) MessageHandlerFunc ¶
func (m *EnvelopeMux) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc)
MessageHandlerFunc allows the definition of a function for handling received messages that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*EnvelopeMux) NotificationHandler ¶
func (m *EnvelopeMux) NotificationHandler(handler NotificationHandler)
func (*EnvelopeMux) NotificationHandlerFunc ¶
func (m *EnvelopeMux) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc)
func (*EnvelopeMux) RequestCommandHandler ¶ added in v0.0.28
func (m *EnvelopeMux) RequestCommandHandler(handler RequestCommandHandler)
func (*EnvelopeMux) RequestCommandHandlerFunc ¶ added in v0.0.28
func (m *EnvelopeMux) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc)
func (*EnvelopeMux) ResponseCommandHandler ¶ added in v0.0.28
func (m *EnvelopeMux) ResponseCommandHandler(handler ResponseCommandHandler)
func (*EnvelopeMux) ResponseCommandHandlerFunc ¶ added in v0.0.28
func (m *EnvelopeMux) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc)
type ExternalAuthentication ¶
type ExternalAuthentication struct { // The authentication token on base64 representation. Token string `json:"token"` // The trusted token issuer. Issuer string `json:"issuer"` }
ExternalAuthentication defines an external authentication scheme, that uses third-party validation.
func (*ExternalAuthentication) GetAuthenticationScheme ¶
func (a *ExternalAuthentication) GetAuthenticationScheme() AuthenticationScheme
type ExternalAuthenticator ¶ added in v0.0.15
type ExternalAuthenticator func(ctx context.Context, identity Identity, token string, issuer string) (*AuthenticationResult, error)
ExternalAuthenticator defines a function for authenticating an identity session using tokens emitted by an issuer.
type GuestAuthentication ¶
type GuestAuthentication struct { }
GuestAuthentication defines a guest authentication scheme.
func (*GuestAuthentication) GetAuthenticationScheme ¶
func (g *GuestAuthentication) GetAuthenticationScheme() AuthenticationScheme
type Identity ¶
type Identity struct { // Name represents the Identity unique name on its domain. Name string // Domain represents the network domain name of the Identity. Domain string }
Identity represents a member of a domain.
func ParseIdentity ¶
ParseIdentity parses the string To a valid Identity.
func (*Identity) IsComplete ¶
IsComplete indicates if all Identity fields has values.
func (Identity) MarshalText ¶
func (Identity) ToNode ¶
ToNode creates a Node instance based on the identity, with an empty value for the instance property.
func (*Identity) UnmarshalText ¶
type InProcessAddr ¶
type InProcessAddr string
func (InProcessAddr) Network ¶
func (i InProcessAddr) Network() string
func (InProcessAddr) String ¶
func (i InProcessAddr) String() string
type JsonDocument ¶
type JsonDocument map[string]interface{}
JsonDocument represents a generic JSON document.
func (*JsonDocument) MediaType ¶
func (d *JsonDocument) MediaType() MediaType
type KeyAuthentication ¶
type KeyAuthentication struct { // Base64 representation of the key Key string `json:"key"` }
KeyAuthentication defines a plain authentication scheme, that uses a key for authentication. Should be used only with encrypted sessions.
func (*KeyAuthentication) GetAuthenticationScheme ¶
func (a *KeyAuthentication) GetAuthenticationScheme() AuthenticationScheme
func (*KeyAuthentication) GetKeyFromBase64 ¶ added in v0.0.41
func (a *KeyAuthentication) GetKeyFromBase64() (string, error)
func (*KeyAuthentication) SetKeyAsBase64 ¶
func (a *KeyAuthentication) SetKeyAsBase64(key string)
type KeyAuthenticator ¶ added in v0.0.15
type KeyAuthenticator func(ctx context.Context, identity Identity, key string) (*AuthenticationResult, error)
KeyAuthenticator defines a function for authenticating an identity session using a key.
type MediaType ¶
type MediaType struct { // Type is the top-level type identifier. // The valid values are text, application, image, audio and video. Type string // Subtype is the MIME subtype. Subtype string // Suffix is the MIME suffix. Suffix string }
MediaType represents a MIME type.
func MediaTypeApplicationJson ¶
func MediaTypeApplicationJson() MediaType
func MediaTypePing ¶ added in v0.0.45
func MediaTypePing() MediaType
func MediaTypeTextPlain ¶
func MediaTypeTextPlain() MediaType
func ParseMediaType ¶
func (MediaType) MarshalText ¶
func (*MediaType) UnmarshalText ¶
type Message ¶
type Message struct { Envelope // MIME Type declaration for the Content of the message. Type MediaType `json:"type"` // Content represents the Message body content Content Document `json:"content"` }
Message encapsulates a document for transport between nodes in a network.
func (*Message) FailedNotification ¶ added in v0.0.5
func (msg *Message) FailedNotification(reason *Reason) *Notification
FailedNotification creates a notification for the current message with the 'failed' event.
func (*Message) MarshalJSON ¶
func (*Message) Notification ¶ added in v0.0.5
func (msg *Message) Notification(event NotificationEvent) *Notification
Notification creates a notification for the current message.
func (*Message) SetContent ¶
func (*Message) UnmarshalJSON ¶
type MessageHandler ¶
type MessageHandler interface { // Match indicates if the specified Message should be handled by the instance. Match(msg *Message) bool // Handle execute an action for the specified Message. // If this method returns an error, it signals to the channel listener to stop. Handle(ctx context.Context, msg *Message, s Sender) error }
MessageHandler defines a handler for processing Message instances received from a channel.
type MessageHandlerFunc ¶
MessageHandlerFunc defines an action to be executed to a Message.
type MessagePredicate ¶
MessagePredicate defines an expression for checking if the specified Message satisfies a condition.
type MessageReceiver ¶
type MessageSender ¶
type Node ¶
type Node struct { Identity // Instance represents the name of the instance used by the node to connect to the network. Instance string }
Node represents an element of a network.
func ContextSessionLocalNode ¶
ContextSessionLocalNode gets the session local node from the context.
func ContextSessionRemoteNode ¶
ContextSessionRemoteNode gets the session remote node from the context.
func (*Node) IsComplete ¶
IsComplete indicates if all Node fields has values.
func (Node) MarshalText ¶
func (*Node) UnmarshalText ¶
type Notification ¶
type Notification struct { Envelope // Event Related event to the notification Event NotificationEvent // In the case of a failed event, the Reason value brings more details about the problem. Reason *Reason }
Notification provides information about events associated to a Message. It can be originated by an intermediate node, like a server, or by the destination of the message.
func (Notification) MarshalJSON ¶
func (not Notification) MarshalJSON() ([]byte, error)
func (*Notification) SetEvent ¶ added in v0.0.32
func (not *Notification) SetEvent(event NotificationEvent) *Notification
func (*Notification) SetFailed ¶ added in v0.0.32
func (not *Notification) SetFailed(reason *Reason) *Notification
func (*Notification) UnmarshalJSON ¶
func (not *Notification) UnmarshalJSON(b []byte) error
type NotificationEvent ¶
type NotificationEvent string
NotificationEvent represent the events that can happen in the message pipeline.
func (NotificationEvent) MarshalText ¶
func (e NotificationEvent) MarshalText() ([]byte, error)
func (*NotificationEvent) UnmarshalText ¶
func (e *NotificationEvent) UnmarshalText(text []byte) error
func (*NotificationEvent) Validate ¶ added in v0.0.5
func (e *NotificationEvent) Validate() error
type NotificationHandler ¶
type NotificationHandler interface { // Match indicates if the specified Notification should be handled by the instance. Match(not *Notification) bool // Handle execute an action for the specified Notification. // If this method returns an error, it signals to the channel listener to stop. Handle(ctx context.Context, not *Notification) error }
NotificationHandler defines a handler for processing Notification instances received from a channel.
type NotificationHandlerFunc ¶
type NotificationHandlerFunc func(ctx context.Context, not *Notification) error
NotificationHandlerFunc defines an action to be executed to a Notification.
type NotificationPredicate ¶
type NotificationPredicate func(not *Notification) bool
NotificationPredicate defines an expression for checking if the specified Notification satisfies a condition.
type NotificationReceiver ¶
type NotificationReceiver interface { ReceiveNotification(ctx context.Context) (*Notification, error) NotChan() <-chan *Notification }
type NotificationSender ¶
type NotificationSender interface {
SendNotification(ctx context.Context, not *Notification) error
}
type Ping ¶ added in v0.0.45
type Ping struct{}
Ping allows the nodes to test the network connectivity.
type PlainAuthentication ¶
type PlainAuthentication struct { // Password is the base64 representation of the password. Password string `json:"password"` }
PlainAuthentication defines a plain authentication scheme, that uses a password for authentication. Should be used only with encrypted sessions.
func (*PlainAuthentication) GetAuthenticationScheme ¶
func (a *PlainAuthentication) GetAuthenticationScheme() AuthenticationScheme
func (*PlainAuthentication) GetPasswordFromBase64 ¶ added in v0.0.41
func (a *PlainAuthentication) GetPasswordFromBase64() (string, error)
func (*PlainAuthentication) SetPasswordAsBase64 ¶
func (a *PlainAuthentication) SetPasswordAsBase64(password string)
type PlainAuthenticator ¶ added in v0.0.15
type PlainAuthenticator func(ctx context.Context, identity Identity, password string) (*AuthenticationResult, error)
PlainAuthenticator defines a function for authenticating an identity session using a password.
type Reason ¶
type Reason struct { Code int `json:"code,omitempty"` // The reason code Description string `json:"description,omitempty"` // The reason description }
Reason represents a known reason for events occurred during the client-server interactions.
type Receiver ¶
type Receiver interface { MessageReceiver NotificationReceiver RequestCommandReceiver ResponseCommandReceiver }
type RequestCommand ¶ added in v0.0.28
type RequestCommand struct { Command URI *URI // URI is the universal identifier of the resource. It should never be nil. }
RequestCommand represents a request for a resource that can be sent to a remote party.
func (*RequestCommand) FailureResponse ¶ added in v0.0.28
func (cmd *RequestCommand) FailureResponse(reason *Reason) *ResponseCommand
FailureResponse creates a failure response Command for the current request.
func (*RequestCommand) MarshalJSON ¶ added in v0.0.28
func (cmd *RequestCommand) MarshalJSON() ([]byte, error)
func (*RequestCommand) SetURI ¶ added in v0.0.34
func (cmd *RequestCommand) SetURI(uri *URI) *RequestCommand
SetURI sets a value to the URI property.
func (*RequestCommand) SetURIString ¶ added in v0.0.34
func (cmd *RequestCommand) SetURIString(s string) *RequestCommand
SetURIString try parse the provided string to a URI and sets it to the request command. It fails silently in case of any parsing error.
func (*RequestCommand) SuccessResponse ¶ added in v0.0.28
func (cmd *RequestCommand) SuccessResponse() *ResponseCommand
SuccessResponse creates a success response Command for the current request.
func (*RequestCommand) SuccessResponseWithResource ¶ added in v0.0.28
func (cmd *RequestCommand) SuccessResponseWithResource(resource Document) *ResponseCommand
SuccessResponseWithResource creates a success response Command for the current request.
func (*RequestCommand) UnmarshalJSON ¶ added in v0.0.28
func (cmd *RequestCommand) UnmarshalJSON(b []byte) error
type RequestCommandHandler ¶ added in v0.0.28
type RequestCommandHandler interface { // Match indicates if the specified RequestCommand should be handled by the instance. Match(cmd *RequestCommand) bool // Handle execute an action for the specified RequestCommand. // If this method returns an error, it signals to the channel listener to stop. Handle(ctx context.Context, cmd *RequestCommand, s Sender) error }
RequestCommandHandler defines a handler for processing Command instances received from a channel.
type RequestCommandHandlerFunc ¶ added in v0.0.28
type RequestCommandHandlerFunc func(ctx context.Context, cmd *RequestCommand, s Sender) error
RequestCommandHandlerFunc defines an action to be executed to a RequestCommand.
type RequestCommandPredicate ¶ added in v0.0.28
type RequestCommandPredicate func(cmd *RequestCommand) bool
RequestCommandPredicate defines an expression for checking if the specified RequestCommand satisfies a condition.
type RequestCommandReceiver ¶ added in v0.0.28
type RequestCommandReceiver interface { ReceiveRequestCommand(ctx context.Context) (*RequestCommand, error) ReqCmdChan() <-chan *RequestCommand }
type RequestCommandSender ¶ added in v0.0.28
type RequestCommandSender interface {
SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
}
type ResponseCommand ¶ added in v0.0.28
type ResponseCommand struct { Command Status CommandStatus // Status indicates the status of the action taken To the resource, in case of a response command. Reason *Reason // Reason indicates the cause for a failure response command. }
ResponseCommand represents a response for a RequestCommand that was issued previously.
func (*ResponseCommand) MarshalJSON ¶ added in v0.0.28
func (cmd *ResponseCommand) MarshalJSON() ([]byte, error)
func (*ResponseCommand) SetStatusFailure ¶ added in v0.0.28
func (cmd *ResponseCommand) SetStatusFailure(r Reason)
func (*ResponseCommand) UnmarshalJSON ¶ added in v0.0.28
func (cmd *ResponseCommand) UnmarshalJSON(b []byte) error
type ResponseCommandHandler ¶ added in v0.0.28
type ResponseCommandHandler interface { // Match indicates if the specified ResponseCommand should be handled by the instance. Match(cmd *ResponseCommand) bool // Handle execute an action for the specified ResponseCommand. // If this method returns an error, it signals to the channel listener to stop. Handle(ctx context.Context, cmd *ResponseCommand, s Sender) error }
ResponseCommandHandler defines a handler for processing Command instances received from a channel.
type ResponseCommandHandlerFunc ¶ added in v0.0.28
type ResponseCommandHandlerFunc func(ctx context.Context, cmd *ResponseCommand, s Sender) error
ResponseCommandHandlerFunc defines an action to be executed to a ResponseCommand.
type ResponseCommandPredicate ¶ added in v0.0.28
type ResponseCommandPredicate func(cmd *ResponseCommand) bool
ResponseCommandPredicate defines an expression for checking if the specified ResponseCommand satisfies a condition.
type ResponseCommandReceiver ¶ added in v0.0.28
type ResponseCommandReceiver interface { ReceiveResponseCommand(ctx context.Context) (*ResponseCommand, error) RespCmdChan() <-chan *ResponseCommand }
type ResponseCommandSender ¶ added in v0.0.28
type ResponseCommandSender interface {
SendResponseCommand(ctx context.Context, cmd *ResponseCommand) error
}
type Sender ¶
type Sender interface { MessageSender NotificationSender RequestCommandSender ResponseCommandSender }
Sender defines a service for sending envelopes to a remote party.
type Server ¶ added in v0.0.15
type Server struct {
// contains filtered or unexported fields
}
Server allows the receiving of Lime connections through multiple transport listeners, like TCP and Websockets. It handles the session negotiation and authentication through the handlers defined in ServerConfig. Finally, it allows the definition of handles for receiving envelopes from the clients.
func NewServer ¶ added in v0.0.15
func NewServer(config *ServerConfig, mux *EnvelopeMux, listeners ...BoundListener) *Server
NewServer creates a new instance of the Server type.
func (*Server) Close ¶ added in v0.0.15
Close stops the server by closing the transport listeners and all active sessions.
func (*Server) ListenAndServe ¶ added in v0.0.15
ListenAndServe starts listening for new connections in the registered transport listeners. This is a blocking call which always returns a non nil error. In case of a graceful closing, the returned error is ErrServerClosed.
type ServerBuilder ¶ added in v0.0.15
type ServerBuilder struct {
// contains filtered or unexported fields
}
ServerBuilder is a helper for building instances of Server. Avoid instantiating it directly, use the NewServerBuilder() function instead.
func NewServerBuilder ¶ added in v0.0.15
func NewServerBuilder() *ServerBuilder
NewServerBuilder creates a new ServerBuilder, which is a helper for building Server instances. It provides a fluent interface for convenience.
func (*ServerBuilder) AutoReplyPings ¶ added in v0.0.45
func (b *ServerBuilder) AutoReplyPings() *ServerBuilder
AutoReplyPings adds a RequestCommandHandler handler to automatically reply ping requests from the remote node.
func (*ServerBuilder) Build ¶ added in v0.0.15
func (b *ServerBuilder) Build() *Server
Build creates a new instance of Server.
func (*ServerBuilder) ChannelBufferSize ¶ added in v0.0.16
func (b *ServerBuilder) ChannelBufferSize(bufferSize int) *ServerBuilder
ChannelBufferSize determines the internal envelope buffer size for the channels.
func (*ServerBuilder) CompressionOptions ¶ added in v0.0.41
func (b *ServerBuilder) CompressionOptions(compOpts ...SessionCompression) *ServerBuilder
CompressionOptions defines the compression options to be used in the session negotiation.
func (*ServerBuilder) Domain ¶ added in v0.0.15
func (b *ServerBuilder) Domain(domain string) *ServerBuilder
Domain sets the server's node domain.
func (*ServerBuilder) EnableExternalAuthentication ¶ added in v0.0.15
func (b *ServerBuilder) EnableExternalAuthentication(a ExternalAuthenticator) *ServerBuilder
EnableExternalAuthentication enables the use of key authentication scheme during the authentication of the client sessions. The provided ExternalAuthenticator function is called for authenticating any session with this scheme.
func (*ServerBuilder) EnableGuestAuthentication ¶ added in v0.0.15
func (b *ServerBuilder) EnableGuestAuthentication() *ServerBuilder
EnableGuestAuthentication enables the use of guest authentication scheme during the authentication of the client sessions. The guest authentication scheme do not require any credentials from the clients.
func (*ServerBuilder) EnableKeyAuthentication ¶ added in v0.0.15
func (b *ServerBuilder) EnableKeyAuthentication(a KeyAuthenticator) *ServerBuilder
EnableKeyAuthentication enables the use of key authentication scheme during the authentication of the client sessions. The provided KeyAuthenticator function is called for authenticating any session with this scheme.
func (*ServerBuilder) EnablePlainAuthentication ¶ added in v0.0.15
func (b *ServerBuilder) EnablePlainAuthentication(a PlainAuthenticator) *ServerBuilder
EnablePlainAuthentication enables the use of plain authentication scheme during the authentication of the client sessions. The provided PlainAuthentication function is called for authenticating any session with this scheme.
func (*ServerBuilder) EnableTransportAuthentication ¶ added in v0.0.15
func (b *ServerBuilder) EnableTransportAuthentication() *ServerBuilder
EnableTransportAuthentication enables the use of transport authentication scheme during the authentication of the client sessions. The transport authentication will delegate the authentication to the session transport and the form of passing the credentials may vary depending on the transport type. For instance, in TCP transport connections, the client certificate used during the mutual TLS negotiation is considered the credentials by the server.
func (*ServerBuilder) EncryptionOptions ¶ added in v0.0.41
func (b *ServerBuilder) EncryptionOptions(encryptOpts ...SessionEncryption) *ServerBuilder
EncryptionOptions defines the encryption options to be used in the session negotiation.
func (*ServerBuilder) Established ¶ added in v0.0.22
func (b *ServerBuilder) Established(established func(sessionID string, c *ServerChannel)) *ServerBuilder
Established is called when a session with a node is established.
func (*ServerBuilder) Finished ¶ added in v0.0.22
func (b *ServerBuilder) Finished(finished func(sessionID string)) *ServerBuilder
Finished is called when an established session with a node is finished.
func (*ServerBuilder) Instance ¶ added in v0.0.15
func (b *ServerBuilder) Instance(instance string) *ServerBuilder
Instance sets the server's node instance.
func (*ServerBuilder) ListenInProcess ¶ added in v0.0.15
func (b *ServerBuilder) ListenInProcess(addr InProcessAddr) *ServerBuilder
ListenInProcess adds a new in-process transport listener with the specified configuration. This method can be called multiple times.
func (*ServerBuilder) ListenTCP ¶ added in v0.0.15
func (b *ServerBuilder) ListenTCP(addr *net.TCPAddr, config *TCPConfig) *ServerBuilder
ListenTCP adds a new TCP transport listener with the specified configuration. This method can be called multiple times.
func (*ServerBuilder) ListenWebsocket ¶ added in v0.0.15
func (b *ServerBuilder) ListenWebsocket(addr *net.TCPAddr, config *WebsocketConfig) *ServerBuilder
ListenWebsocket adds a new Websocket transport listener with the specified configuration. This method can be called multiple times.
func (*ServerBuilder) MessageHandler ¶ added in v0.0.15
func (b *ServerBuilder) MessageHandler(handler MessageHandler) *ServerBuilder
MessageHandler allows the registration of a MessageHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) MessageHandlerFunc ¶ added in v0.0.15
func (b *ServerBuilder) MessageHandlerFunc(predicate MessagePredicate, f MessageHandlerFunc) *ServerBuilder
MessageHandlerFunc allows the registration of a function for handling received messages that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) MessagesHandlerFunc ¶ added in v0.0.16
func (b *ServerBuilder) MessagesHandlerFunc(f MessageHandlerFunc) *ServerBuilder
MessagesHandlerFunc allows the registration of a function for handling all received messages. This handler should be the last one to be registered, since it will capture all messages received by the client.
func (*ServerBuilder) Name ¶ added in v0.0.15
func (b *ServerBuilder) Name(name string) *ServerBuilder
Name sets the server's node name.
func (*ServerBuilder) NotificationHandler ¶ added in v0.0.15
func (b *ServerBuilder) NotificationHandler(handler NotificationHandler) *ServerBuilder
NotificationHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) NotificationHandlerFunc ¶ added in v0.0.15
func (b *ServerBuilder) NotificationHandlerFunc(predicate NotificationPredicate, f NotificationHandlerFunc) *ServerBuilder
NotificationHandlerFunc allows the registration of a function for handling received notifications that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) NotificationsHandlerFunc ¶ added in v0.0.16
func (b *ServerBuilder) NotificationsHandlerFunc(f NotificationHandlerFunc) *ServerBuilder
NotificationsHandlerFunc allows the registration of a function for handling all received notifications. This handler should be the last one to be registered, since it will capture all notifications received by the client.
func (*ServerBuilder) Register ¶ added in v0.0.24
func (b *ServerBuilder) Register(register func(ctx context.Context, candidate Node, c *ServerChannel) (Node, error)) *ServerBuilder
Register is called for the client Node address registration. It receives a candidate node from the client and should return the effective node address that will be assigned to the session.
func (*ServerBuilder) RequestCommandHandler ¶ added in v0.0.28
func (b *ServerBuilder) RequestCommandHandler(handler RequestCommandHandler) *ServerBuilder
RequestCommandHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) RequestCommandHandlerFunc ¶ added in v0.0.28
func (b *ServerBuilder) RequestCommandHandlerFunc(predicate RequestCommandPredicate, f RequestCommandHandlerFunc) *ServerBuilder
RequestCommandHandlerFunc allows the registration of a function for handling received commands that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) RequestCommandsHandlerFunc ¶ added in v0.0.28
func (b *ServerBuilder) RequestCommandsHandlerFunc(f RequestCommandHandlerFunc) *ServerBuilder
RequestCommandsHandlerFunc allows the registration of a function for handling all received commands. This handler should be the last one to be registered, since it will capture all commands received by the client.
func (*ServerBuilder) ResponseCommandHandler ¶ added in v0.0.28
func (b *ServerBuilder) ResponseCommandHandler(handler ResponseCommandHandler) *ServerBuilder
ResponseCommandHandler allows the registration of a NotificationHandler. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) ResponseCommandHandlerFunc ¶ added in v0.0.28
func (b *ServerBuilder) ResponseCommandHandlerFunc(predicate ResponseCommandPredicate, f ResponseCommandHandlerFunc) *ServerBuilder
ResponseCommandHandlerFunc allows the registration of a function for handling received commands that matches the specified predicate. Note that the registration order matters, since the receiving process stops when the first predicate match occurs.
func (*ServerBuilder) ResponseCommandsHandlerFunc ¶ added in v0.0.28
func (b *ServerBuilder) ResponseCommandsHandlerFunc(f ResponseCommandHandlerFunc) *ServerBuilder
ResponseCommandsHandlerFunc allows the registration of a function for handling all received commands. This handler should be the last one to be registered, since it will capture all commands received by the client.
type ServerChannel ¶
type ServerChannel struct {
// contains filtered or unexported fields
}
func NewServerChannel ¶
func NewServerChannel(t Transport, bufferSize int, serverNode Node, sessionID string) *ServerChannel
func (*ServerChannel) EstablishSession ¶
func (c *ServerChannel) EstablishSession( ctx context.Context, compOpts []SessionCompression, encryptOpts []SessionEncryption, schemeOpts []AuthenticationScheme, authenticate func(context.Context, Identity, Authentication) (*AuthenticationResult, error), register func(context.Context, Node, *ServerChannel) (Node, error)) error
EstablishSession establishes a server channel with transport options negotiation and authentication.
func (ServerChannel) Established ¶
func (c ServerChannel) Established() bool
func (*ServerChannel) FailSession ¶
func (c *ServerChannel) FailSession(ctx context.Context, reason *Reason) error
func (*ServerChannel) FinishSession ¶
func (c *ServerChannel) FinishSession(ctx context.Context) error
func (ServerChannel) NotChan ¶
func (c ServerChannel) NotChan() <-chan *Notification
func (ServerChannel) ProcessCommand ¶
func (c ServerChannel) ProcessCommand(ctx context.Context, reqCmd *RequestCommand) (*ResponseCommand, error)
func (ServerChannel) RcvDone ¶ added in v0.0.19
func (c ServerChannel) RcvDone() <-chan struct{}
RcvDone signals when the channel receiver goroutine is done. This usually indicates that the session with the remote node was finished.
func (ServerChannel) RemoteNode ¶
func (c ServerChannel) RemoteNode() Node
func (ServerChannel) ReqCmdChan ¶ added in v0.0.28
func (c ServerChannel) ReqCmdChan() <-chan *RequestCommand
func (ServerChannel) RespCmdChan ¶ added in v0.0.28
func (c ServerChannel) RespCmdChan() <-chan *ResponseCommand
func (ServerChannel) SendMessage ¶
func (ServerChannel) SendNotification ¶
func (c ServerChannel) SendNotification(ctx context.Context, not *Notification) error
func (ServerChannel) SendRequestCommand ¶ added in v0.0.28
func (c ServerChannel) SendRequestCommand(ctx context.Context, cmd *RequestCommand) error
func (ServerChannel) SendResponseCommand ¶ added in v0.0.28
func (c ServerChannel) SendResponseCommand(ctx context.Context, cmd *ResponseCommand) error
func (ServerChannel) State ¶
func (c ServerChannel) State() SessionState
type ServerConfig ¶ added in v0.0.15
type ServerConfig struct { Node Node // Node represents the server's address. CompOpts []SessionCompression // CompOpts defines the compression options to be used in the session negotiation. EncryptOpts []SessionEncryption // EncryptOpts defines the encryption options to be used in the session negotiation. SchemeOpts []AuthenticationScheme // SchemeOpts defines the authentication schemes that should be presented to the clients during session establishment. Backlog int // Backlog defines the size of the listener's pending connections queue. ChannelBufferSize int // ChannelBufferSize determines the internal envelope buffer size for the channels. // Authenticate is called for authenticating a client session. // It should return an AuthenticationResult instance with DomainRole different of DomainRoleUnknown for a successful authentication. Authenticate func(ctx context.Context, identity Identity, a Authentication) (*AuthenticationResult, error) // Register is called for the client Node address registration. // It receives a candidate node from the client and should return the effective node address that will be assigned // to the session. Register func(ctx context.Context, candidate Node, c *ServerChannel) (Node, error) // Established is called when a session with a node is established. Established func(sessionID string, c *ServerChannel) // Finished is called when an established session with a node is finished. Finished func(sessionID string) }
ServerConfig define the configurations for a Server instance.
func NewServerConfig ¶ added in v0.0.15
func NewServerConfig() *ServerConfig
NewServerConfig creates a new instance of ServerConfig with the default configuration values.
type Session ¶
type Session struct { Envelope // State informs or changes the state of a session. // Only the server can change the session state, but the client can request // the state transition. State SessionState // EncryptionOptions represent the options provided by the server during the session negotiation. EncryptionOptions []SessionEncryption // Encryption represents the encryption option selected for the session. // This property is provided by the client in the negotiation and by the // server in the confirmation after that. Encryption SessionEncryption // Compression options provided by the server during the session negotiation. CompressionOptions []SessionCompression // The compression option selected for the session. // This property is provided by the client in the negotiation and by the // server in the confirmation after that. Compression SessionCompression // List of available authentication schemas for session authentication provided // by the server. SchemeOptions []AuthenticationScheme // The authentication scheme option selected for the session. // This property must be present if the property authentication is defined. Scheme AuthenticationScheme // Authentication data, related To the selected schema. // Information like password sent by the client or round-trip data sent by the server. Authentication Authentication // In cases where the client receives a session with failed state, // this property should provide more details about the problem. Reason *Reason }
The Session envelope is used for the negotiation, authentication and establishment of the communication channel between the client and a server.
func (*Session) MarshalJSON ¶
func (*Session) SetAuthentication ¶
func (s *Session) SetAuthentication(a Authentication)
func (*Session) UnmarshalJSON ¶
type SessionCompression ¶
type SessionCompression string
SessionCompression Defines the valid session compression values.
type SessionEncryption ¶
type SessionEncryption string
SessionEncryption Defines the valid session encryption values.
type SessionState ¶
type SessionState string
SessionState Defines the supported session states
func (SessionState) MarshalText ¶
func (s SessionState) MarshalText() ([]byte, error)
func (SessionState) Step ¶
func (s SessionState) Step() int
func (*SessionState) UnmarshalText ¶
func (s *SessionState) UnmarshalText(text []byte) error
func (SessionState) Validate ¶ added in v0.0.5
func (s SessionState) Validate() error
type StdoutTraceWriter ¶
type StdoutTraceWriter struct {
// contains filtered or unexported fields
}
StdoutTraceWriter Implements a TraceWriter that uses the standard output for writing send and received envelopes.
func (StdoutTraceWriter) ReceiveWriter ¶
func (t StdoutTraceWriter) ReceiveWriter() *io.Writer
func (StdoutTraceWriter) SendWriter ¶
func (t StdoutTraceWriter) SendWriter() *io.Writer
type TCPConfig ¶
type TCPConfig struct { ReadLimit int64 // ReadLimit defines the limit for buffered data in read operations. TraceWriter TraceWriter // TraceWriter sets the trace writer for tracing connection envelopes TLSConfig *tls.Config ConnBuffer int }
type TextDocument ¶ added in v0.0.32
type TextDocument string
TextDocument represents a plain document.
func (TextDocument) MediaType ¶ added in v0.0.32
func (d TextDocument) MediaType() MediaType
type TraceWriter ¶
type TraceWriter interface { SendWriter() *io.Writer // SendWriter returns the sendWriter for the transport send operations ReceiveWriter() *io.Writer // ReceiveWriter returns the sendWriter for the transport receive operations }
TraceWriter Enable request tracing for network transports.
func NewStdoutTraceWriter ¶
func NewStdoutTraceWriter() TraceWriter
type Transport ¶
type Transport interface { io.Closer Send(ctx context.Context, e envelope) error // Send sends an envelope to the remote node. Receive(ctx context.Context) (envelope, error) // Receive receives an envelope from the remote node. SupportedCompression() []SessionCompression // SupportedCompression enumerates the supported compression options for the transport. Compression() SessionCompression // Compression returns the current transport compression option. SetCompression(ctx context.Context, c SessionCompression) error // SetCompression defines the compression mode for the transport. SupportedEncryption() []SessionEncryption // SupportedEncryption enumerates the supported encryption options for the transport. Encryption() SessionEncryption // Encryption returns the current transport encryption option. SetEncryption(ctx context.Context, e SessionEncryption) error // SetEncryption defines the encryption mode for the transport. Connected() bool // Connected indicates if the transport is connected. LocalAddr() net.Addr // LocalAddr returns the local endpoint address. RemoteAddr() net.Addr // RemoteAddr returns the remote endpoint address. }
Transport defines the basic features for a Lime communication mean
func DialInProcess ¶
func DialInProcess(addr InProcessAddr, bufferSize int) (Transport, error)
DialInProcess creates a new in process transport connection to the specified path.
type TransportAuthentication ¶
type TransportAuthentication struct { }
TransportAuthentication defines a transport layer authentication scheme.
func (*TransportAuthentication) GetAuthenticationScheme ¶
func (a *TransportAuthentication) GetAuthenticationScheme() AuthenticationScheme
type TransportListener ¶
type TransportListener interface { io.Closer Listen(ctx context.Context, addr net.Addr) error // Listen start listening for new transport connections. Accept(ctx context.Context) (Transport, error) // Accept a new transport connection. }
TransportListener Defines a listener interface for the transports.
func NewInProcessTransportListener ¶
func NewInProcessTransportListener(addr InProcessAddr) TransportListener
func NewTCPTransportListener ¶
func NewTCPTransportListener(config *TCPConfig) TransportListener
func NewWebsocketTransportListener ¶
func NewWebsocketTransportListener(config *WebsocketConfig) TransportListener
type URI ¶
type URI struct {
// contains filtered or unexported fields
}
URI defines a Lime resource identifier. It can be represented in the short form (like '/presence') or in the absolute form, that includes the URI scheme and resource owner identity (like 'lime://name@domain/presence').
func ParseLimeURI ¶
func (*URI) MarshalText ¶
func (*URI) UnmarshalText ¶
type WebsocketConfig ¶
type WebsocketConfig struct { TLSConfig *tls.Config TraceWriter TraceWriter // TraceWriter sets the trace writer for tracing connection envelopes EnableCompression bool ConnBuffer int // CheckOrigin returns true if the request Origin header is acceptable. If // CheckOrigin is nil, then a safe default is used: return false if the // Origin request header is present and the origin host is not equal to // request Host header. // // A CheckOrigin function should carefully validate the request origin to // prevent cross-site request forgery. CheckOrigin func(r *http.Request) bool }