-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define, document, and release a stable (v1) version. #46
Comments
Candidates for removal:
|
I would like to simplify the My current thinking is to consolidate "simple" and "static" into a single concept: A "static" service implementation is one without a meaningful constructor. Instead of a separate type for single-throw services, the package can have a top-level ✅ 4bb7b22 |
Possible server simplification: Re-combine the ❌ Decided not to do this; conflating these two doesn't save much and the semantics are different enough to be worth keeping separate. |
Possible error simplification: Export most or all of the fields of the ✅ b11415d |
Possible server simplification: Now that the server is exposed to handlers via the context, there is no longer any need for separate top-level To get rid of ✅ d4361e1 |
Simplify fixtures, remove unneeded method. #46 (comment)
- 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)
This constructor is not carrying its weight in API surface. It cannot handle unexported methods, and the names it extracts are based on Go-specific lexical rules rather than whatever a service may require. Simplify test fixtures and remove unnecessary support code. See issue #46.
This constructor is not carrying its weight in API surface. It cannot handle unexported methods, and the names it extracts are based on Go-specific lexical rules rather than whatever a service may require. Simplify test fixtures and remove unnecessary support code. See issue #46.
- 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)
- 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)
Now that the *Server can be recovered directly from the handler context, there is no longer a need for separate top-level helper functions in the package. Remove these to simplify the package API. Note that this is a breaking change. To update existing use, replace: jrpc2.PushNotify(ctx, m, p) ⇒ jrpc2.ServerFromContext(ctx).Notify(ctx, m, p) jrpc2.PushCall(ctx, m, p) ⇒ jrpc2.ServerFromContext(ctx).Callback(ctx, m, p) jrpc2.CancelRequest(ctx, id) ⇒ jrpc2.ServerFromContext(ctx).CancelRequest(id) jrpc2.ServerMetrics(ctx) ⇒ jrpc2.ServerFromContext(ctx).Metrics() See issue #46.
- 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)
Remove the parameter-wrapping context plumbing hooks. This was meant as a transparent way to encode context settings, but it was a lot of overhead for relatively little use. ✅ #82 |
Replace the custom metrics collector plumbing with the standard ✅ #89 |
Simplify the Handler type to be a plain function instead of an interface. ✅ #90 |
Rip out the registration mechanism for error code values. In practice any package that wants to define custom codes has to keep track of them anyway, so that the client can coordinate with the server. The additional hook for cosmetics in the default error string is just not worthwhile. ✅ #91 |
Look for usage of the server.Run function and see if we can get rid of it or adapt the use. ✅ #92 |
In practice any package that wants to define custom codes has to keep track of them anyway, so that the client can coordinate with the server. The additional hook for cosmetics in the default error string is just not worthwhile. Updates #46.
In practice any package that wants to define custom codes has to keep track of them anyway, so that the client can coordinate with the server. The additional hook for cosmetics in the default error string is just not worthwhile. Updates #46.
This has no meaningful use to justify its existence in the API. Updates #46.
This has no meaningful use to justify its existence in the API. Updates #46.
Another step toward #46. Maintenance: - Update module dependencies. - handler: fix an outdated comment - Remove the custom queue implementation. (#93) Breaking changes: - code: remove the code registration hooks (#91) - server: remove the Run helper (#92) Although these changes are breaking, I surveyed existing usage visible from the search engine, and did not find anything likely to care.
- Remove the RPCServerInfo client helper, it was unused outside tests. - Remove the methodFunc wrapper type, it is no longer necessary. - Fix up tests. Updates #46.
- Remove the RPCServerInfo client helper, it was unused outside tests. - Remove the methodFunc wrapper type, it is no longer necessary. - Collapse the now-vestigial special.go back into server.go. - Fix up tests. Updates #46.
Convert handler.Func into a plain type alias and remove the repetition of the type signature in the Check plumbing. ✅ e1278b5 |
I think the package has reached a stable enough API that it's time to cut a v1. The remaining tasks will be:
I haven't decided whether to bother with a separate release branch; I think probably not. If a v2 release becomes desirable I'll clone the code into a submodule, it's not that big a project. |
There is no longer any reason to have a distinct type for this, since the interface was removed and jrpc2.Handler was converted to a type alias. Clean up all the uses of handler.Func and use jrpc2.Handler instead. Updates #46.
I'm not sure if it needs to change the API in any way to account for this - probably not necessarily backwards incompatible way - but unless you're already keeping eye, I'd recommend checking out the proposal for structured logging which was recently accepted: golang/go#56345 |
Thanks for flagging that. I don't think the server and client debug logs would benefit much from adding structure, but if an application wants to use structured logs in handlers, it would be easy to plumb through a logger via the type slogKey struct{}
func WithLogger(ctx context.Context, s *slog.Logger) context.Context {
return context.WithValue(ctx, slogKey{}, s)
}
func Logger(ctx context.Context) *slog.Logger {
if s := ctx.Value(slogKey{}); s != nil {
return s.(*slog.Logger)
}
return slog.Default()
}
opts := &jrpc2.ServerOptions{
NewContext: func() context.Context {
return WithLogger(context.Background(), myLogger)
},
}
func Handle(ctx context.Context, req *jrpc2.Request) (any, error) {
Logger(ctx).Info("hello from handler", "method", req.Method())
return "ok", nil
} or words to that effect. I'm a little disappointed that this API got approved as-written, but I don't see any obvious compatibility concerns. If we later need to bolt structured logging on to the existing debug facility, it wouldn't be too bad to add another hook to the options. |
v1.0.0 is now tagged and available. |
This module is currently versioned for development (v0).
Where practical, I try to avoid breaking API changes. However, when I do need to change the API I've adopted the convention of incrementing the minor version number. For other changes I will generally only increment the patch number. Hence,
v0.11.1
tov0.11.2
should be a "safe" (non-breaking) upgrade, whereasv0.12.1
tov0.13.0
includes visible API effects that may require client code to be updated.This issue was created to track the definition and release of a stable (v1) version. Broadly: I would like to trim down the API as much as possible for such a release.
Summary of Changes
package jrpc2
Error
type, remove unnecessary methods (b11415d, c677bac, 14261a3, 37bcf3b)jrpc2.Network
return signature (Update the Network helper to return a tuple. #51)package jhttp
package channel
Sender
andReceiver
interfaces (65bf9ad)WithTrigger
wrapper channel (a5d1a82)package handler
NewService
constructor (0ee4b78)Varint
framing (2534128)package server
Other
jctx
package (Remove support for parameter injection. #82)metrics
package and useexpvar
instead (Replace idiosyncratic metrics collector with expvar. #89)The text was updated successfully, but these errors were encountered: