compose-net / compose

Lightweight framework to assist in application composition
Apache License 2.0
6 stars 6 forks source link

Expose extensions interface #102

Open ghost opened 9 years ago

ghost commented 9 years ago

I have been reading up a bit on Karyon from Netflix and had a small idea.

If you want to perform metric gathering on method calls to produce flame graphs etc, you would have to something akin to the following:

using(Profiler.Record("StepName"))
     someObject.SomeMethod();

I propose that compose adds an extension point to the service proxy so that you can intercept methods and perform so or all of the following without the need for the boiler plate code above:

So given the following proxied method call:

someObject.SomeMethod();

I expected the generated code to look something like:

class SomeObjectServiceProxy
{
    IEnumerable<Interceptor> Interceptors { get; set; }
    ISomeObject Service { get; set; }

    void SomeMethod()
    {
        foreach(var interceptor in Interceptors)
            interceptor.Intercept(); // Optional :: allow blocking/returning out here

        Service.SomeMethod();

        foreach(var interceptor in Interceptors)
            interceptor.Intercept();
    }
}

This could help prevent a lot of boiler code for logging/timing info

mattridgway commented 9 years ago

Are you making the case for using AOP there?

Sent from Outlook

ghost commented 9 years ago

It's an idea, not sure whether its a good one or not at this stage. Can't really think of use cases outside of monitoring/logging, so maybe an API dedicated to that would be better? I wouldn't do it AOP though, this would be dynamically generated with the dynamic proxies.

smudge202 commented 9 years ago

I think this can already be achieved by implementing the dynamic interfaces. It's not something I'd want to cook in to Compose (not a fan of this kind of logging). We could achieve what you've asked without AOP which is nice; perhaps the goal here should be to provide a sample project that implements this method logging by using the existing extensibility points? (Assuming it is possible; it may not be...)

ghost commented 9 years ago

Oh I'm not a fan of AOP. if it can be implemented using existing extension points then great. Might be worth a weekend hack to find out. It's more the ability to rather than baking in logging etc. logging is just the example

smudge202 commented 9 years ago

If you fancy picking this up as a weekend hack-o-stream I can be around to provide some guidance?

smudge202 commented 8 years ago

Are you still interested in this one, @sblackler ? Just trying to think which milestone we should aim for, 1.0.1 or later?

ghost commented 8 years ago

Go for later