lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AndyPook <>
Subject [GitHub] lucenenet issue #209: RFC: LUCENENET-565: Porting of Lucene.Net.Replicator
Date Sat, 29 Jul 2017 17:04:29 GMT
Github user AndyPook commented on the issue:
    @jeme you are quite right, that is equivalent.
    A bit OCD, but I have a tendency to try and encapsulate features in discrete pieces. If
this got much more complex that a one liner then I think splitting it out into a separate
class would be a "good thing", easier to create tests for...
    I agree with @NightOwl888. It seems that this "api" is very well defined and opinionated
(esp if you want interop) so leaving this to an end developer to reimplement each time would
be error prone or cut&paste boiler plate. 
    In short, keeping this well defined service api outside of mvc world with it's attributes,
reflection, media type formatters etc. would also be a good thing
    Although I may be missing some nuances and be off in the weeds somewhere.
    If the path is defined as ```/<context>/<shard>/<action>``` then maybe
using routing would be helpful. Maybe something like...
    		public static void UseLuceneReplicator2(this IApplicationBuilder app, string prefix,
object indexService)
    			var routeBuilder = new RouteBuilder(app);
    			routeBuilder.MapGet(prefix+ "/{context}/{shard}/{action}/{*path}", async context =>
    				var req = context.Request;
    				await context.Response.WriteAsync($"<p>{DateTime.Now.ToString()}</p>");
    				await context.Response.WriteAsync($"<p>indexService={indexService.ToString()}</p>");
    				await context.Response.WriteAsync($"<p>path={req.Path}</p>");
    				await context.Response.WriteAsync($"<p>context={context.GetRouteValue("context")}</p>");
    				await context.Response.WriteAsync($"<p>shard={context.GetRouteValue("shard")}</p>");
    				await context.Response.WriteAsync($"<p>action={context.GetRouteValue("action")}</p>");
    				await context.Response.WriteAsync($"<ul>");
    				foreach (var q in req.Query)
    					await context.Response.WriteAsync($"<li>{q.Key}={q.Value}</li>");
    				await context.Response.WriteAsync($"</ul>");
    			var routes = routeBuilder.Build();
    Again I'd suggest taking the lamdba body out into something more discrete, this is just
a demo.
    Just throwing stuff at the wall to see what sticks :)

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message