Skip to content

Commit

Permalink
Wrap nats connections as reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
longsleep committed Apr 8, 2016
1 parent acae8e7 commit b363c21
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions go/natsconnection/natsconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ var DefaultURL = nats.DefaultURL

// Connection implements the wrapped nats.Conn.
type Connection struct {
nats.Conn
*nats.Conn
}

// EncodedConnection implements the wrapped nats.EncodedConn.
type EncodedConnection struct {
nats.EncodedConn
*nats.EncodedConn
}

// NewConnection creates a connetion to the default NATS server
Expand Down Expand Up @@ -55,7 +55,7 @@ func NewConnection() (*Connection, error) {
return nil, err
}

return &Connection{*nc}, nil
return &Connection{nc}, nil
}

// NewJSONEncodedConnection creates a JSON-encoded connetion to the
Expand All @@ -67,11 +67,11 @@ func NewJSONEncodedConnection() (*EncodedConnection, error) {
if err != nil {
return nil, err
}
ec, err := nats.NewEncodedConn(&nc.Conn, nats.JSON_ENCODER)
ec, err := nats.NewEncodedConn(nc.Conn, nats.JSON_ENCODER)
if err != nil {
return nil, err
}
return &EncodedConnection{*ec}, nil
return &EncodedConnection{ec}, nil
}

// EstablishConnection is a blocking way to create and establish
Expand Down Expand Up @@ -129,9 +129,9 @@ func EstablishJSONEncodedConnection(timeout *time.Duration) (*EncodedConnection,
if err != nil {
return nil, err
}
ec, err := nats.NewEncodedConn(&nc.Conn, nats.JSON_ENCODER)
ec, err := nats.NewEncodedConn(nc.Conn, nats.JSON_ENCODER)
if err != nil {
return nil, err
}
return &EncodedConnection{*ec}, nil
return &EncodedConnection{ec}, nil
}

0 comments on commit b363c21

Please sign in to comment.