From 9a227025be0ac51be947e2072ccc7646299c3b65 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Fri, 11 Jun 2021 17:57:10 -0400 Subject: [PATCH] handler: Implement the Service interface trivially. --- handler/handler.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/handler/handler.go b/handler/handler.go index 147185d..dd676bc 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -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 @@ -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: //