Documentation
¶
Overview ¶
Author of this file is https://github.com/nsf https://github.com/nsf/jsondiff/blob/master/LICENSE
Index ¶
- Constants
- Variables
- func FlateCompress(input string) ([]byte, error)
- func FlateDecompress(input []byte) ([]byte, error)
- func GZipCompress(input string) ([]byte, error)
- func GZipDecompress(input []byte) ([]byte, error)
- type AuthHandler
- type Client
- func (s *Client) Close()
- func (s *Client) Connect(ctx context.Context) (err error)
- func (s *Client) ManualReconnect()
- func (s *Client) Send(msgType int, message []byte) (err error)
- func (s *Client) SetAuthHandler(authH AuthHandler)
- func (s *Client) SetErrorHandler(errH ErrorHandler)
- func (s *Client) SetKeepAliveHandler(keep KeepAlive)
- func (s *Client) SetMessageHandler(msgH MessageHandler)
- type Config
- type CustomLogger
- type DialerFunc
- type Difference
- type DuplexConnector
- type ErrorHandler
- type KeepAlive
- type MessageHandler
- type Options
- type Tag
Constants ¶
const ( TextMessage = 1 BinaryMessage = 2 PingMessage = 9 PongMessage = 10 )
Variables ¶
Functions ¶
func FlateCompress ¶ added in v1.1.1
func FlateDecompress ¶ added in v1.1.1
func GZipCompress ¶
func GZipDecompress ¶
Types ¶
type AuthHandler ¶
type Client ¶ added in v1.1.1
type Client struct {
// contains filtered or unexported fields
}
func NewStubborn ¶
func (*Client) ManualReconnect ¶ added in v1.1.1
func (s *Client) ManualReconnect()
func (*Client) SetAuthHandler ¶ added in v1.1.1
func (s *Client) SetAuthHandler(authH AuthHandler)
Set auth callback handler
func (*Client) SetErrorHandler ¶ added in v1.1.1
func (s *Client) SetErrorHandler(errH ErrorHandler)
Set error handler excluding messages
func (*Client) SetKeepAliveHandler ¶ added in v1.1.1
SetKeepAliveHandler keep connection intact and trace it state
func (*Client) SetMessageHandler ¶ added in v1.1.1
func (s *Client) SetMessageHandler(msgH MessageHandler)
Set message handler excluding errors
type Config ¶
type Config struct { IsReconnectable bool // default message type MessageType int // use your favourite logger Logger CustomLogger // use your favourite client Dialerf DialerFunc AuthTimeOut time.Duration // it is easier to define expected error because exceptions always unexpected :) UnimportantErrs []error }
type CustomLogger ¶ added in v1.1.1
type CustomLogger interface { Infoln(args ...interface{}) Debugln(args ...interface{}) Errorln(args ...interface{}) }
type DialerFunc ¶
type DialerFunc func(ctx context.Context) (DuplexConnector, error)
type Difference ¶
type Difference int
const ( FullMatch Difference = iota SupersetMatch NoMatch FirstArgIsInvalidJson SecondArgIsInvalidJson BothArgsAreInvalidJson )
func CompareJSON ¶
func CompareJSON(a, b []byte, opts *Options) (Difference, string)
Compares two JSON documents using given options. Returns difference type and a string describing differences.
FullMatch means provided arguments are deeply equal.
SupersetMatch means first argument is a superset of a second argument. In this diffContext being a superset means that for each object or array in the hierarchy which don't match exactly, it must be a superset of another one. For example:
{"a": 123, "b": 456, "c": [7, 8, 9]}
Is a superset of:
{"a": 123, "c": [7, 8]}
NoMatch means there is no match.
The rest of the difference types mean that one of or both JSON documents are invalid JSON.
Returned string uses a format similar to pretty printed JSON to show the human-readable difference between provided JSON documents. It is important to understand that returned format is not a valid JSON and is not meant to be machine readable.
func (Difference) String ¶
func (d Difference) String() string
type DuplexConnector ¶ added in v0.3.0
type ErrorHandler ¶
type ErrorHandler func(err error)
type MessageHandler ¶
type MessageHandler func(resp []byte)
type Options ¶
type Options struct { Normal Tag Added Tag Removed Tag Changed Tag Prefix string Indent string PrintTypes bool ChangedSeparator string }
func DefaultConsoleOptions ¶
func DefaultConsoleOptions() Options
Provides a set of options that are well suited for console output. Options use ANSI foreground color escape sequences to highlight changes.
func DefaultHTMLOptions ¶
func DefaultHTMLOptions() Options
Provides a set of options that are well suited for HTML output. Works best inside <pre> tag.
func DefaultJSONOptions ¶
func DefaultJSONOptions() Options
Provides a set of options in JSON format that are fully parseable.