refactor command routing similar to http.ServeMux

Issue #65 closed
Jon repo owner created an issue

Provides better maintainability, testability, and lays the foundation for easier plugin support.

  • benchmark perf tradeoffs between regex and string matches
  • investigate abstracting commands as command.CommandFunc

Comments (2)

  1. Jon reporter

    Initial impl ubenchmarks

    C:\Users\Jon\Documents\GoDev\mygo\src\bitbucket.org\jonforums\uru>go test -run NONE -bench=.
    PASS
    BenchmarkRegexCompare   20000000               104 ns/op
    BenchmarkStringCompare  2000000000               0.30 ns/op
    BenchmarkMultiStringCompare     2000000000               0.30 ns/op
    BenchmarkSwitchRouter     500000              3865 ns/op
    BenchmarkCommandRouter   1000000              1212 ns/op
    
  2. Jon reporter

    Refactor command routing internals. Closes #65

    Simpler, more performant, and more extensible command routing. Replace switch-and-regex based routing with string comparing, function pointer based CommandRouter component.

    Initial impl micro-benchmark results:

    BenchmarkSwitchRouter 500000 3865 ns/op BenchmarkCommandRouter 1000000 1212 ns/op

    → <<cset 6df3c4d6ed7c>>

  3. Log in to comment