juju: github.com/wallyworld/juju/rpc/jsoncodec Index | Files

package jsoncodec

import "github.com/wallyworld/juju/rpc/jsoncodec"

The jsoncodec package provides a JSON codec for the rpc package.


Package Files

codec.go conn.go

func DumpRequest Uses

func DumpRequest(hdr *rpc.Header, body interface{}) []byte

DumpRequest returns JSON-formatted data representing the RPC message with the given header and body, as it would be written by Codec.WriteMessage. If the body cannot be marshalled as JSON, the data will hold a JSON string describing the error.

type Codec Uses

type Codec struct {
    // contains filtered or unexported fields

Codec implements rpc.Codec for a connection.

func New Uses

func New(conn JSONConn) *Codec

New returns an rpc codec that uses conn to send and receive messages.

func NewNet Uses

func NewNet(conn io.ReadWriteCloser) *Codec

NewNet returns an rpc codec that uses the given connection to send and receive messages.

func NewWebsocket Uses

func NewWebsocket(conn *websocket.Conn) *Codec

NewWebsocket returns an rpc codec that uses the given websocket connection to send and receive messages.

func (*Codec) Close Uses

func (c *Codec) Close() error

func (*Codec) ReadBody Uses

func (c *Codec) ReadBody(body interface{}, isRequest bool) error

func (*Codec) ReadHeader Uses

func (c *Codec) ReadHeader(hdr *rpc.Header) error

func (*Codec) WriteMessage Uses

func (c *Codec) WriteMessage(hdr *rpc.Header, body interface{}) error

type JSONConn Uses

type JSONConn interface {
    // Send sends a message.
    Send(msg interface{}) error
    // Receive receives a message into msg.
    Receive(msg interface{}) error
    Close() error

JSONConn sends and receives messages to an underlying connection in JSON format.

func NetJSONConn Uses

func NetJSONConn(conn io.ReadWriteCloser) JSONConn

func NewWebsocketConn Uses

func NewWebsocketConn(conn *websocket.Conn) JSONConn

NewWebsocketConn returns a JSONConn implementation that uses the given connection for transport.

Package jsoncodec imports 8 packages (graph). Updated 2019-04-23. Refresh now. Tools for package owners.