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

PmdbClient Write() vs. WriteEncoded()? #4

Open
00pauln00 opened this issue Dec 19, 2023 · 2 comments
Open

PmdbClient Write() vs. WriteEncoded()? #4

00pauln00 opened this issue Dec 19, 2023 · 2 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@00pauln00
Copy link
Owner

After reviewing users of both of these, I'm wondering if WriteEncoded() is necessary? Why do we not simply apply the request object to ReqED and the response to ResponseED? What are we gaining by performing encoding / decoding out? For example, in leaseClient.go why not just use leaseLib.LeaseReq -> ReqED and leaseLib.LeaseRep -> ResponseED?

One upside of removing external encoding / decoding is that WriteEncodedAndGetResponse() could be deprecated if we can detect the presence of ResponseED -- if present on write, then we'd know to expect a response buffer and how to decode it.

func (obj *PmdbClientObj) WriteEncoded(reqArgs *PmdbReqArgs) (unsafe.Pointer,

@00pauln00 00pauln00 added the help wanted Extra attention is needed label Dec 19, 2023
@ashwini-8 ashwini-8 self-assigned this Jan 5, 2024
@ashwini-8
Copy link
Collaborator

ashwini-8 commented Jan 6, 2024

We need both Write() and WriteEncoded() as
Write() is used by covid and foodpalace we have just the server and client, where we encode the request and pass it to the server.
where as in WriteEncoded() we use it in ncpc and contraol plane where we have http layer as well, where we encode the request from application and pass through http, if we don't use WriteEncoded function we will have overhead of decoding and encoding at proxy. If not, we can remove normal write function and have only WriteEncoded function instead.

@00pauln00
Copy link
Owner Author

00pauln00 commented Jan 8, 2024

I understand that we must encode / decode based on the situation. My point is why can we not simply test for the presence of the encode / decode interfaces in PmdbReqArgs and perform the operation if the interfaces are present?

In the examples you give above, covid-app and foodpalace would set ReqED and ResponseED accordingly and other users, like ncpc would not.

  23 │ type PmdbReqArgs struct {                                                       
  24 │         Rncui       string                                                      
  25 │         ReqED       interface{}     <<< ---
  26 │         ResponseED  interface{}     <<< ---
  27 │         ReqByteArr  []byte                                                     
  28 │         Response    *[]byte                                                     
  29 │         ReplySize   *int64                                                      
  30 │         GetResponse int                                                         
  31 │         ZeroCopyObj *RDZeroCopyObj                                              
  32 │ }                                              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants