{"action":"opened","issue":{"url":"https://api.github.com/repos/envoyproxy/envoy/issues/5270","repository_url":"https://api.github.com/repos/envoyproxy/envoy","labels_url":"https://api.github.com/repos/envoyproxy/envoy/issues/5270/labels{/name}","comments_url":"https://api.github.com/repos/envoyproxy/envoy/issues/5270/comments","events_url":"https://api.github.com/repos/envoyproxy/envoy/issues/5270/events","html_url":"https://github.com/envoyproxy/envoy/issues/5270","id":389898618,"node_id":"MDU6SXNzdWUzODk4OTg2MTg=","number":5270,"title":"Clarify and simplify the ADS and xDS over gRPC implementations","user":{"login":"fredlas","id":43351173,"node_id":"MDQ6VXNlcjQzMzUxMTcz","avatar_url":"https://avatars0.githubusercontent.com/u/43351173?v=4","gravatar_id":"","url":"https://api.github.com/users/fredlas","html_url":"https://github.com/fredlas","followers_url":"https://api.github.com/users/fredlas/followers","following_url":"https://api.github.com/users/fredlas/following{/other_user}","gists_url":"https://api.github.com/users/fredlas/gists{/gist_id}","starred_url":"https://api.github.com/users/fredlas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredlas/subscriptions","organizations_url":"https://api.github.com/users/fredlas/orgs","repos_url":"https://api.github.com/users/fredlas/repos","events_url":"https://api.github.com/users/fredlas/events{/privacy}","received_events_url":"https://api.github.com/users/fredlas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-11T18:36:46Z","updated_at":"2018-12-11T18:36:46Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The current implementations of xDS over gRPC and ADS are hard for someone new to the code to understand, or at least, hard for this particular new someone :)\r\n\r\nHere is the situation: there is GrpcMuxImpl, GrpcSubscriptionImpl, GrpcMuxSubscriptionImpl, and GrpcManagedMuxSubscriptionImpl. GrpcSubscriptionImpl owns both a GrpcMuxImpl and a GrpcManagedMuxSubscriptionImpl. GrpcManagedMuxSubsciptionImpl holds a reference to the GrpcMuxImpl its owner owns, and also owns a GrpcMuxSubscriptionImpl.\r\n\r\nWhat does someone who wants to write code that uses an xDS client, or ADS client, do? The answer is use GrpcSubscriptionImpl or GrpcMuxImpl, respectively, but I had a very hard time figuring that out, even after talking with people who already got it.\r\n\r\nThe Subscription interface sounds like it should be the conceptual attachment point for all users of xDS. That made me expect ADS would also operate through GrpcSubscriptionImpl: that you would create something like a GrpcMuxImpl as the single object actually communicating with the server, but then you would associate your Subscriptions to it and interact only with them. I was therefore confused when I realized that every newly created GrpcSubscriptionImpl would create a new gRPC stream.\r\n\r\nThe GrpcMux abstract interface has comments saying it can be used for either single xDS or ADS, but that's not quite true: single xDS uses GrpcSubscriptionImpl. That class is basically a wrapper around GrpcMux, but that's an implementation detail that should be hidden from the user. Since you wouldn't expect something called mux to need to be involved when you only want to work with a single thing, it's confusing to see this class suggested for xDS.\r\n\r\nGrpcSubscriptionImpl is just a wrapper around GrpcMuxSubscriptionImpl. That is to mediate between two cases: whether the Subscription should own the GrpcMux (single xDS), or it should not (ADS). I don't think a wrapper class is the right way to do that. Rather, maybe GrpcSubscriptionImpl could have an additional absl::optional<GrpcMuxPtr> field, and the grpc_mux_ field that exists in both classes could be a reference in the new single class. (Or it could just be a shared_ptr; not sure if that would be considered justified in this case).\r\n\r\nAdding comments to the implementations will certainly help a lot. However, I think an overhaul of the class names would also greatly help, along with the GrpcMuxSubscription refactor mentioned above. I opened this as an issue rather than just getting started on making changes so we could discuss 1) if the renames/refactor are a good idea, and if so 2) what exactly to rename to. To get things started, I propose\r\nGrpcMuxImpl->AdsMuxImpl\r\nGrpcSubscriptionImpl->XdsSubscriptionImpl\r\nGrpcMuxSubscriptionImpl->deleted\r\nGrpcManagedMuxSubsciptionImpl->not yet sure, but I suspect it can be pulled into XdsSubscriptionImpl in the same way I'm proposing for GrpcMuxSubscriptionImpl.\r\n\r\nAlso, I wonder: could GrpcMuxCallbacks and SubscriptionCallbacks be merged? The only difference is that SubscriptionCallbacks' onConfigUpdate takes typed resource protos. What if we had only SubscriptionCallbacks, and ADS gave GrpcMux several of them, one for each type? I think they would fit naturally as a field of ApiState. Maybe this idea should be considered separately, though.\r\n\r\nI know that is a lot to digest, but please let me know what you think!"}}
{"actor":{"display_login":"fredlas"}}