Skip to content

Commit

Permalink
refactor: remove name from CallInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Oct 23, 2024
1 parent 72b5e7b commit 59201fc
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 187 deletions.
6 changes: 3 additions & 3 deletions cmd/kod/internal/generate_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ func (g *generator) generateRegisteredComponents(p printFn) {
return %s_local_stub{
impl: info.Impl.(%s),
interceptor: info.Interceptor,
name: info.Name,
} }`,
notExported(name), g.componentRef(comp))
refNames := make([]string, 0, len(comp.refs))
Expand Down Expand Up @@ -768,12 +767,14 @@ func (g *generator) generateLocalStubs(p printFn) {

var b strings.Builder
for _, comp := range g.components {
if comp.isMain {
continue
}

stub := notExported(comp.intfName()) + "_local_stub"
p(`// %s is a local stub implementation of [%s].`, stub, g.tset.genTypeString(comp.intf))
p(`type %s struct{`, stub)
p(` impl %s`, g.componentRef(comp))
p(` name string`)
p(` interceptor interceptor.Interceptor`)
p(`}`)

Expand Down Expand Up @@ -821,7 +822,6 @@ func (g *generator) generateLocalStubs(p printFn) {

p(`info := interceptor.CallInfo {
Impl: s.impl,
Component: s.name,
FullMethod: %s,
}
`, comp.fullMethodNameVar(m.Name()))
Expand Down
19 changes: 0 additions & 19 deletions examples/helloworld/kod_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions interceptor/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
type CallInfo struct {
// The impl of the called component.
Impl any
// The component name of the called method.
Component string
// The full name of the called method, in the format of "package/service.method".
FullMethod string
}
Expand Down
1 change: 0 additions & 1 deletion interceptor/kmetric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func Interceptor() interceptor.Interceptor {
err = invoker(ctx, info, req, reply)

as := attribute.NewSet(
attribute.String("component", info.Component),
attribute.String("method", info.FullMethod),
)

Expand Down
2 changes: 1 addition & 1 deletion interceptor/ktrace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Interceptor() interceptor.Interceptor {
info.FullMethod,
trace.WithSpanKind(trace.SpanKindInternal),
trace.WithAttributes(
attribute.String("component", info.Component),
attribute.String("method", info.FullMethod),
),
)
}
Expand Down
Loading

0 comments on commit 59201fc

Please sign in to comment.