Skip to content

add Handle() callback to support Service-specific signal handling#28

Open
mreiferson wants to merge 2 commits intojudwhite:mainfrom
mreiferson:signal-handler
Open

add Handle() callback to support Service-specific signal handling#28
mreiferson wants to merge 2 commits intojudwhite:mainfrom
mreiferson:signal-handler

Conversation

@mreiferson
Copy link
Copy Markdown

This does what I said I was going to do in nsqio/nsq#1331

service.Context() is called after Init() (and after Start()) on unixes,
so some users did not expect or test with Context() called before Init()
@mreiferson
Copy link
Copy Markdown
Author

mreiferson commented Aug 15, 2021

I've pulled in #29 here so I can more easily get a build going

@judwhite
Copy link
Copy Markdown
Owner

@mreiferson I usually provide a package level function such as IsErrStop to check error types. It mimics how os handles errors, but it's different than io.EOF like you have here.

I like that the IsErrXXX way takes some of the guess work out, such as the caller asking "Is this the right way to check this error? Can I depend on the author considering errors as part of their API contract?" The Go team is explicit about io.EOF not changing.

I don't have a hard stance for public projects, especially since we don't have to worry about unwrapping. What are your thoughts? I'm open.

@mreiferson
Copy link
Copy Markdown
Author

I usually provide a package level function such as IsErrStop to check error types. It mimics how os handles errors, but it's different than io.EOF like you have here.

@judwhite I'm not sure that cleans things up in this case? The caller (Service provider) needs to return a specific error type to go-svc, not check an error type go-svc returns.

@ploxiln
Copy link
Copy Markdown

ploxiln commented Aug 16, 2021

Yeah, this is the opposite direction of the usual pattern.

This error returned by the user's callback to this library, is really a kind of sentinel value. It could alternatively be a boolean, or an enum of some kind ...

side note: the commit at the head of this branch is now referenced by https://github.com/nsqio/nsq/blob/v1.2.1/go.mod#L20 so we should theoretically be sure to keep this commit alive in mreiferson's fork indefinitely, maybe on another new branch so that this one can have requested changes rebased/squashed before merge

@mreiferson
Copy link
Copy Markdown
Author

Yep, pushed to https://github.com/mreiferson/go-svc/tree/nsq-v1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants