Skip to content

metamorph/weekly-ten

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weekly Challenge #10

The Weekly Programming Challenge : http://weblog.jamisbuck.org/2016/10/1/weekly-programming-challenge-10.html

Installation

Requires Leiningen to build:

lein uberjasr

Usage

To start the server:

$ java -jar target/uberjar/weekly-ten-0.1.0-SNAPSHOT-standalone.jar --server <port>

To launch a client that will send a query to the server:

$ java -jar target/uberjar/weekly-ten-0.1.0-SNAPSHOT-standalone.jar --client <host> <port> <query>

The query engine is really simple - it simply returns the query reversed.

The Phteven Variant

$ java -jar target/uberjar/weekly-ten-0.1.0-SNAPSHOT-standalone.jar --pherver <port>

This starts a server that will delegate queries to Phteven.IO :-)

Use it like so:

$ java -jar target/uberjar/weekly-ten-0.1.0-SNAPSHOT-standalone.jar --client <host> <port> "Hello, Steven"

> Querying server localhost:9999 : Hello, Steven => 
> Hello, Phteven

Design

The server is built in a way that allows a custom ‘handler’ to be defined. When launching from the command-line the simple-protocol-handler is used.

The server uses good old threads to support multiple concurrent clients.

The simple-protocol-handler defines the protocol described in the challenge.

The server can be started in embedded mode like so:

(weekly-ten.server/start-server handler-function port)

where the handler-function is a function that takes two parameters: a java.io.InputStream (for reading from the client) and a java.io.OutputStream (for writing to the client). The accepting connections, managing resources etc. is handled outside of this.

So - in theory - implementing the HTTP server should be possible by simple adding another “handler function”.

Due to lack of time I decided to skip the HTTP client/server challenge. Instead I decided to implement a simple HTTP POST client, and to implement a query-handler that send the query to Phteven.IO to get a phtevenized response :-).

Bugs

Most likely.

License

Copyright © 2016

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Weekly Programming Challenge #10 - http://weblog.jamisbuck.org/2016/10/1/weekly-programming-challenge-10.html

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •