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

Locator interceptors #38

Open
spion-h4 opened this issue May 7, 2019 · 2 comments
Open

Locator interceptors #38

spion-h4 opened this issue May 7, 2019 · 2 comments

Comments

@spion-h4
Copy link
Collaborator

spion-h4 commented May 7, 2019

In order to add features such as logging and tracing, it would be nice if h4bff supported interceptors for the locator.

Motivation:

Lets say you would like to implement an XRay tracer that will give you a listing of all the service method calls for a request. You've made a tracing proxy that wraps a service method calls with the right xray xray logging calls. How to apply it to all service instances?

Sketch API / motivation

app.addServiceInterceptor((ServiceClass, oldGetter) => { 
  if (ServiceClass.traced || TracedClasses.has(ServiceClass)) { 
    return xrayProxy(oldGetter(ServiceClass)); 
  } 
  else { return oldGetter(ServiceClass); } 
})

This would wrap all services annotated with a "traced" property (or those explicitly added to the "TracedClasses" map) with a tracing proxy. Its sort of like a middleware system, but not to be confused with middleware - MW pertains to individual client requests (one per service context) while interceptors are for each service instantiation.

@spion-h4
Copy link
Collaborator Author

spion-h4 commented May 7, 2019

The interceptor is general enough to actually implement overrides using it, instead of having it as a primitive:

app.addServiceInterceptor((ServiceClass, oldGetter) => { 
  if (overrides.has(ServiceClass)) { 
    let NewClass = overrides.get(ServiceClass); 
    return oldGetter(NewClass); 
  }
  else { return oldGetter(ServiceClass); } 
})

@spion-h4
Copy link
Collaborator Author

spion-h4 commented May 7, 2019

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

No branches or pull requests

1 participant