Documentation ¶
Overview ¶
NPM-GO is a Go client for the NPM HTTP API based on rabbithole (https://github.com/michaelklishin/rabbit-hole)
All HTTP API operations are accessible via `npmgo.Client`, which should be instantiated with `npmgo.NewClient`.
// URI, username, password rmqc, _ = NewClient("http://127.0.0.1:15672", "guest", "guest")
Index ¶
- func JSONMarshal(v interface{}, safeEncoding bool) ([]byte, error)
- func PathEscape(s string) string
- type BrokerContext
- type Client
- func (c *Client) CloseConnection(name string) (res *http.Response, err error)
- func (c *Client) CreateToken(info TokenSettings) (res Objects, err error)
- func (c *Client) DeleteToken(id string) (res *http.Response, err error)
- func (c *Client) GetConnection(name string) (rec *ConnectionInfo, err error)
- func (c *Client) GetToken(id string) (rec Objects, err error)
- func (c *Client) ListConnections() (rec []ConnectionInfo, err error)
- func (c *Client) ListTokens() (rec []Objects, err error)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SetTransport(transport *http.Transport)
- func (c *Client) Whoami() (rec *WhoamiInfo, err error)
- type ConnectionInfo
- type ErrorResponse
- type MessageStats
- type Objects
- type Port
- type Properties
- type RateDetailSample
- type RateDetails
- type TokenInfo
- type TokenSettings
- type WhoamiInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONMarshal ¶
func PathEscape ¶
PathEscape escapes the string so it can be safely placed inside a URL path segment.
Types ¶
type BrokerContext ¶
type BrokerContext struct { Node string `json:"node"` Description string `json:"description"` Path string `json:"path"` Port Port `json:"port"` Ignore bool `json:"ignore_in_use"` }
RabbitMQ context (Erlang app) running on a node
type Client ¶
type Client struct { // URI of a NPM server node to use, not including the path, e.g. http://127.0.0.1:15672. Endpoint string // Username to use. This RabbitMQ user must have the "management" tag. Username string // Password to use. Password string // Token to use Token string // contains filtered or unexported fields }
func NewTLSClient ¶
func NewTLSClient(uri string, username string, password string, transport *http.Transport) (me *Client, err error)
Creates a client with a transport; it is up to the developer to make that layer secure.
func (*Client) CloseConnection ¶
func (*Client) CreateToken ¶
func (c *Client) CreateToken(info TokenSettings) (res Objects, err error)
Creates a new token.
func (*Client) DeleteToken ¶
Deletes token.
func (*Client) GetConnection ¶
func (c *Client) GetConnection(name string) (rec *ConnectionInfo, err error)
func (*Client) ListConnections ¶
func (c *Client) ListConnections() (rec []ConnectionInfo, err error)
func (*Client) ListTokens ¶
Returns a list of all users in a cluster.
func (*Client) SetTimeout ¶
SetTimeout changes the HTTP timeout that the Client will use. By default there is no timeout.
func (*Client) SetTransport ¶
SetTransport changes the Transport Layer that the Client will use.
func (*Client) Whoami ¶
func (c *Client) Whoami() (rec *WhoamiInfo, err error)
type ConnectionInfo ¶
type ConnectionInfo struct { // Connection name Name string `json:"name"` // Node the client is connected to Node string `json:"node"` // Number of open channels Channels int `json:"channels"` // Connection state State string `json:"state"` // Connection type, network (via AMQP client) or direct (via direct Erlang client) Type string `json:"type"` // Server port Port Port `json:"port"` // Client port PeerPort Port `json:"peer_port"` // Server host Host string `json:"host"` // Client host PeerHost string `json:"peer_host"` // Last connection blocking reason, if any LastBlockedBy string `json:"last_blocked_by"` // When connection was last blocked LastBlockedAge string `json:"last_blocked_age"` // True if connection uses TLS/SSL UsesTLS bool `json:"ssl"` // Client certificate subject PeerCertSubject string `json:"peer_cert_subject"` // Client certificate validity PeerCertValidity string `json:"peer_cert_validity"` // Client certificate issuer PeerCertIssuer string `json:"peer_cert_issuer"` // TLS/SSL protocol and version SSLProtocol string `json:"ssl_protocol"` // Key exchange mechanism SSLKeyExchange string `json:"ssl_key_exchange"` // SSL cipher suite used SSLCipher string `json:"ssl_cipher"` // SSL hash SSLHash string `json:"ssl_hash"` // Protocol, e.g. AMQP 0-9-1 or MQTT 3-1 Protocol string `json:"protocol"` User string `json:"user"` // Virtual host Vhost string `json:"vhost"` // Heartbeat timeout Timeout int `json:"timeout"` // Maximum frame size (AMQP 0-9-1) FrameMax int `json:"frame_max"` // A map of client properties (name, version, capabilities, etc) ClientProperties Properties `json:"client_properties"` // Octets received RecvOct uint64 `json:"recv_oct"` // Octets sent SendOct uint64 `json:"send_oct"` RecvCount uint64 `json:"recv_cnt"` SendCount uint64 `json:"send_cnt"` SendPending uint64 `json:"send_pend"` // Ingress data rate RecvOctDetails RateDetails `json:"recv_oct_details"` // Egress data rate SendOctDetails RateDetails `json:"send_oct_details"` }
Provides information about connection to a RabbitMQ node.
type ErrorResponse ¶
type ErrorResponse struct { StatusCode int Message string `json:"error"` Reason string `json:"reason"` }
func (ErrorResponse) Error ¶
func (rme ErrorResponse) Error() string
type MessageStats ¶
type MessageStats struct { Publish int64 `json:"publish"` PublishDetails RateDetails `json:"publish_details"` Deliver int64 `json:"deliver"` DeliverDetails RateDetails `json:"deliver_details"` DeliverNoAck int64 `json:"deliver_noack"` DeliverNoAckDetails RateDetails `json:"deliver_noack_details"` DeliverGet int64 `json:"deliver_get"` DeliverGetDetails RateDetails `json:"deliver_get_details"` Redeliver int64 `json:"redeliver"` RedeliverDetails RateDetails `json:"redeliver_details"` Get int64 `json:"get"` GetDetails RateDetails `json:"get_details"` GetNoAck int64 `json:"get_no_ack"` GetNoAckDetails RateDetails `json:"get_no_ack_details"` Ack int64 `json:"ack"` AckDetails RateDetails `json:"ack_details"` }
Basic published messages statistics
type Properties ¶
type Properties map[string]interface{}
Extra arguments as a map (on queues, bindings, etc)
type RateDetailSample ¶
RateDetailSample single touple
type RateDetails ¶
type RateDetails struct { Rate float32 `json:"rate"` Samples []RateDetailSample `json:"samples"` }
Rate of change of a numerical value
type TokenSettings ¶
type TokenSettings struct { //Password is required again to create token Password string `json:"password"` Readonly bool `json:"readonly"` CidrWhitelist []string `json:"cidr_whitelist"` }
Settings used to create users. Tags must be comma-separated.
type WhoamiInfo ¶
type WhoamiInfo struct {
Username string `json:"username"`
}