lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENENET-565) Port Lucene.Net.Replicator
Date Sat, 29 Jul 2017 17:05:00 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16106180#comment-16106180
] 

ASF GitHub Bot commented on LUCENENET-565:
------------------------------------------

Github user AndyPook commented on the issue:

    https://github.com/apache/lucenenet/pull/209
  
    @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...
    
    ```csharp
    		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();
    			app.UseRouter(routes);
    		}
    ```
    
    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 :)


> Port Lucene.Net.Replicator
> --------------------------
>
>                 Key: LUCENENET-565
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-565
>             Project: Lucene.Net
>          Issue Type: Task
>          Components: Lucene.Net.Replicator
>    Affects Versions: Lucene.Net 4.8.0
>            Reporter: Shad Storhaug
>            Priority: Minor
>              Labels: features
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message