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

pubsub example does not work #3

Closed
yyzcode opened this issue Jun 10, 2022 · 0 comments · Fixed by go-micro/go-micro#2514
Closed

pubsub example does not work #3

yyzcode opened this issue Jun 10, 2022 · 0 comments · Fixed by go-micro/go-micro#2514

Comments

@yyzcode
Copy link

yyzcode commented Jun 10, 2022

func (s *Sub) Process(ctx context.Context, event *proto.Event) error {
	md, _ := metadata.FromContext(ctx)
	log.Logf("[pubsub.1] Received event %+v with metadata %+v\n", event, md)
	// do something with event
	return nil
}

// Alternatively a function can be used
func subEv(ctx context.Context, event *proto.Event) error {
	md, _ := metadata.FromContext(ctx)
	log.Logf("[pubsub.2] Received event %+v with metadata %+v\n", event, md)
	// do something with event
	return nil
}

in this demo, the handler function of subscribe topic used a pointer parameter, it will cause an panic error: "file=server/rpc_router.go:512 level=error panic recovered: reflect.Value.Addr of unaddressable value".

I tried use value parameter to fix and it works.

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 a pull request may close this issue.

1 participant