Skip to content
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

Add NamerFunc to allow ordinary functions as Namer #65

Merged
merged 3 commits into from
Nov 14, 2023

Conversation

Tiscs
Copy link
Contributor

@Tiscs Tiscs commented Oct 16, 2023

Added a type NamerFunc, it's an adapter to allow the use of ordinary functions as Namer, it's useful when you want to use a function as a Namer but don't want to define a new type.

// example.go
reflector := grpcreflect.NewReflector(NamerFunc(func() []string {
    return s.svcs
}))
s.mux.Handle(grpcreflect.NewHandlerV1(reflector))
s.mux.Handle(grpcreflect.NewHandlerV1Alpha(reflector))

@CLAassistant
Copy link

CLAassistant commented Oct 16, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@jhump jhump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tiscs, I apologize for the long delay before getting you feedback. This seems like a reasonable idea. Please see suggestion to tighten up the Go docs.

grpcreflect.go Outdated Show resolved Hide resolved
Co-authored-by: Joshua Humphries <2035234+jhump@users.noreply.github.com>
@Tiscs Tiscs requested a review from jhump November 13, 2023 17:35
@jhump jhump merged commit c7eb14d into connectrpc:main Nov 14, 2023
@Tiscs Tiscs deleted the feature/namer_func branch November 15, 2023 02:20
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