Skip to content

Commit

Permalink
Expose the default handlers
Browse files Browse the repository at this point in the history
This allows an implementation to reuse one of the implementations
if they would like to implement a replacement for the other.
  • Loading branch information
jsouthworth committed Sep 17, 2017
1 parent 29c37e6 commit 023e603
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func Dial(address string) (*Conn, error) {
if err != nil {
return nil, err
}
return newConn(tr, newDefaultHandler(), newDefaultSignalHandler())
return newConn(tr, NewDefaultHandler(), NewDefaultSignalHandler())
}

// DialHandler establishes a new private connection to the message bus specified by address, using the supplied handlers.
Expand All @@ -174,7 +174,7 @@ func DialHandler(address string, handler Handler, signalHandler SignalHandler) (

// NewConn creates a new private *Conn from an already established connection.
func NewConn(conn io.ReadWriteCloser) (*Conn, error) {
return NewConnHandler(conn, newDefaultHandler(), newDefaultSignalHandler())
return NewConnHandler(conn, NewDefaultHandler(), NewDefaultSignalHandler())
}

// NewConnHandler creates a new private *Conn from an already established connection, using the supplied handlers.
Expand Down
10 changes: 8 additions & 2 deletions default_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ func newIntrospectIntf(h *defaultHandler) *exportedIntf {
return newExportedIntf(methods, true)
}

func newDefaultHandler() *defaultHandler {
//NewDefaultHandler returns an instance of the default
//call handler. This is useful if you want to implement only
//one of the two handlers but not both.
func NewDefaultHandler() *defaultHandler {
h := &defaultHandler{
objects: make(map[ObjectPath]*exportedObj),
defaultIntf: make(map[string]*exportedIntf),
Expand Down Expand Up @@ -214,7 +217,10 @@ func (obj *exportedIntf) isFallbackInterface() bool {
return obj.includeSubtree
}

func newDefaultSignalHandler() *defaultSignalHandler {
//NewDefaultSignalHandler returns an instance of the default
//signal handler. This is useful if you want to implement only
//one of the two handlers but not both.
func NewDefaultSignalHandler() *defaultSignalHandler {
return &defaultSignalHandler{}
}

Expand Down

0 comments on commit 023e603

Please sign in to comment.