-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: Simplify the API for static and single-run services.
- Rework NewStatic as "Static", which returns a plain constructor. - Remove the "Simple" type and move its Run method to a top-level function. - Update usage examples. #46 (comment)
- Loading branch information
1 parent
122d5e8
commit aa82e5c
Showing
7 changed files
with
35 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/creachadair/jrpc2" | ||
"github.com/creachadair/jrpc2/channel" | ||
) | ||
|
||
// Run starts a server for svc on the given channel, and blocks until it | ||
// returns. The server exit status is reported to the service, and the error | ||
// value is returned. | ||
// | ||
// If the caller does not need the error value and does not want to wait for | ||
// the server to complete, call Run in a goroutine. | ||
func Run(ch channel.Channel, svc Service, opts *jrpc2.ServerOptions) error { | ||
assigner, err := svc.Assigner() | ||
if err != nil { | ||
return err | ||
} | ||
srv := jrpc2.NewServer(assigner, opts).Start(ch) | ||
stat := srv.WaitStatus() | ||
svc.Finish(stat) | ||
return stat.Err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.