Giter Club home page Giter Club logo

auction-house's Introduction

TASK DEFINITION

See "Online Code Test - Auction House".txt

HOW TO RUN

Open solution in VC2019, click Build, then Start. VC2019 comes with NuGet pre-installed and nuget.org source pre-configured out of the box. These are required to download the Boost library.

LIBRARIES

Boost.Asio is used for Async TCP server implementation. Under Windows, it uses IOCPs, under Linux epoll, thus can handle >10k simultaneous users. Also, it provides timers on the event loop.
Boost.Test is used for Unit Tests.
Easylogging++ is used for easy logging. Boost.Log is too complicated and requires additional libs. Easylogging++ is distributed as a source code and included in the project itself.
I've implemented my persistent storage with a write-ahead log just for the sake of the test task. In an actual project, I encourage you to use in such a scenario the Rocksdb.
I've implemented my client protocol parser - ChunkTokenizer - which parses incoming data stream into commands and protects from malicious input. For such a simple case, this will do. For more sophisticated cases, one should use LEX and YACC or Boost.Qi (EBNF and PEG parsers).

SOLUTION OVERVIEW

Required functionality and bonus items are implemented.
Sell and buy orders (Orderbook) are transient. Items on hold are ephemeral too. Inventory (items and funds) are persistent with ACID guarantees (D partly as I haven't added fsync, which also doesn't guarantee Durability, it is better to do a distributed database). This means in case of crash or restart, orders are cleared, and all items on hold are released, funds are safe.
One cannot buy immediately, only make a bid, then matching happens, and after expiration time order completes.
The choices above are based on my experience with EPEX exchange and Markedskraft.
There are not many comments in the code. This is done intentionally. I prefer to write a code to increase Cohesion and decrease Coupling. Classes do one thing, their names, method names, and argument names and types are self-explanatory (except in a few places where I've added comments). I'm ok with any other coding standard, though.

CLASSES

Auction implements the business logic of an Auction
Db, DbTransaction, InMemoryDb, FileBackedDB (uses FileBackedMap) are to organize in memory and persistent storage.
DummyTimer, AsyncTimer implement Timer interface and are used in UTs and in an event loop respectively.
AsyncTcpServer and AsyncTcpSession implement the communication with clients. AsyncTcpSession uses ChunkTokenizer to handle input.
And a few auxiliary classes.

auction-house's People

Contributors

adolgarev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.