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

how to rewrite attachment #189

Open
champly opened this issue May 15, 2020 · 3 comments
Open

how to rewrite attachment #189

champly opened this issue May 15, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@champly
Copy link
Contributor

champly commented May 15, 2020

背景

service mesh环境下,需要在 sidecar 中解析dubboattachment,并根据需求添加一些自定义的参数进去,就像SetHeader一样,然后重新构建 dubbo

问题

如果使用hessian.NewDecoder,传递的参数没有对象是可以的,如果参数中有对象会报错,参考 #163 的解决办法,使用 hessian.NewDecoderWithSkip可以解决,但是重新构建的时候arg类型是interface{},值是nil

解决

能否多提供一个Decode方法,直接返回[]byte内容,重新构建的时候直接encode.Append(arg)就可以重新构建dubbo

@champly
Copy link
Contributor Author

champly commented May 21, 2020

solve

decode

  1. use hessian.NewDecoderWithSkip Decode dubboVersion/path/version/method/argsTypes/args/attachment info.
  2. create hessian encode object, encode attachment.
  3. calc encode len

encode

  1. encode.Append(payload[len(payload]-attachment_encode_len)
  2. encode.Encode(attachment)

@AlexStocks AlexStocks added the good first issue Good for newcomers label May 21, 2020
@RAJASHEKARGUNAGANTI
Copy link

hello folks ..!
I am good at java and I wanted to resolve this issue so please explain this issue some more detail as this is my first contribution .

@tiltwind
Copy link
Contributor

tiltwind commented Feb 5, 2023

some materials:

dubbo rpc attachments belongs to the Variable Part, but u can't get where it starts from, u must skip the parts before it, include Dubbo version, Service name, Service version, Method name, Method parameter types, Method arguments.
But for hessian2 serialization protocol , u must decode the data to find where it ends with. There is't a length to tell the length of the data. So it costs a lot for the sidecar of mesh to update the attachments.

And I'm not sure whether the MOSN has already implemented this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants