Documentation
¶
Overview ¶
Package socketmap implements the Sendmail socketmap protocol
Index ¶
Constants ¶
const MaxSize = 100000
MaxSize is the maximum size of a socketmap message in bytes.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the network address addr and then calls Serve with handler to handle requests on incoming connections.
ListenAndServe always returns a non-nil error.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(network, addr string, opts ...ClientOption) *Client
NewClient returns a new Client that connects to a socketmap server with network and address. You can pass additional opts. The defaults are using maximum of 10 parallel connections and a net.Dialer with a 10 seconds timeout.
func (*Client) Close ¶
func (c *Client) Close()
Close finishes all connections. Waits until all connections are closed. After the call to Close all LookupContext calls will return an error.
func (*Client) Lookup ¶
Lookup calls LookupContext with context.Background as ctx.
func (*Client) LookupContext ¶
func (c *Client) LookupContext(ctx context.Context, lookup, key string) (value string, ok bool, err error)
LookupContext lookup key in the lookup map of c. If ctx is Done while looking up key, err will be ctx.Err(). If the map has a value, ok will be true. If map does not have a value for key, value will be "" and ok will be false. If there is a communication error or the socketmap server returns an error, err will be non-nil.
type ClientOption ¶
type ClientOption func(clientOptions)
func WithDialer ¶
func WithDialer(dialer Dialer) ClientOption
func WithMaxSize ¶
func WithMaxSize(maxSize int32) ClientOption
type Handler ¶
A Handler responds to a Sendmail socketmap request. ctx is a context you can pass down to potentially long-running functions. lookup and key are the two parsed request variables (the map name and the map key to look up).
A Handler should return found = true when key was found in lookup. Then result holds the value associated with key. If the Handler returns a non-nil err this error gets passed back to the client. You can use PermanentError or TimeoutError to signal a permanent or timeout error to the client. All other errors are returned as temporary errors.
type PermanentError ¶
type PermanentError struct {
Reason string
}
func (PermanentError) Error ¶
func (e PermanentError) Error() string
func (PermanentError) Temporary ¶
func (PermanentError) Temporary() bool
func (PermanentError) Timeout ¶
func (PermanentError) Timeout() bool
type TimeoutError ¶
type TimeoutError struct {
Reason string
}
func (TimeoutError) Error ¶
func (e TimeoutError) Error() string
func (TimeoutError) Temporary ¶
func (TimeoutError) Temporary() bool
func (TimeoutError) Timeout ¶
func (TimeoutError) Timeout() bool
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
log-socketmap
command
Command log-socketmap is a socketmap server that always returns NOTFOUND and logs all requests.
|
Command log-socketmap is a socketmap server that always returns NOTFOUND and logs all requests. |
|
test-socketmap
command
Command test-socketmap is a test client for a socketmap server
|
Command test-socketmap is a test client for a socketmap server |