Skip to content

Commit

Permalink
handler: Implement the Service interface trivially.
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Jun 11, 2021
1 parent ff6de6a commit 9a22702
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func (m Map) Names() []string {
return names
}

// Assigner returns m itself as an assigner for use in a Service.
// It never reports an error.
func (m Map) Assigner() (jrpc2.Assigner, error) { return m, nil }

// Finish is a no-op implementation satisfying part of the Service interface.
func (Map) Finish(jrpc2.Assigner, jrpc2.ServerStatus) {}

// A ServiceMap combines multiple assigners into one, permitting a server to
// export multiple services under different names.
type ServiceMap map[string]jrpc2.Assigner
Expand Down Expand Up @@ -71,6 +78,13 @@ func (m ServiceMap) Names() []string {
return all
}

// Assigner returns m itself as an assigner for use in a Service.
// It never reports an error.
func (m ServiceMap) Assigner() (jrpc2.Assigner, error) { return m, nil }

// Finish is a no-op implementation satisfying part of the Service interface.
func (ServiceMap) Finish(jrpc2.Assigner, jrpc2.ServerStatus) {}

// New adapts a function to a jrpc2.Handler. The concrete value of fn must be a
// function with one of the following type signatures:
//
Expand Down

0 comments on commit 9a22702

Please sign in to comment.