Skip to content

livestorm/matthieu-backend-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Livestorm Back-End Hiring Test (Golang)

This test is part of our hiring process for Golang developers. Apply now

This test should take you around one hour. Keep it simple and straightforward.

Specifications

The goal is to write a simple in-memory PubSub service over WebSocket.

  • The service will be a websocket server clients can connect to.
  • Clients can subscribe to channels and publish payloads to channels.
  • When a payload is published to a channel, all clients subscribed to that channel will receive thepayload.
  • Channels and payloads are both arbitrary strings provided by clients.

We only expect you to write the server part of the application, and will provide you with a scaffolding implementation for the client logic and executables.

Protocol

The server and clients will communicate by sending and receiving websocket text messages containing JSON-encoded data.

{
  "type": "<message_type>",
  "data": {
    <message_data>
  }
}

All message types are already defined in pubsub/protocol.go.

Subscribe

To subscribe to a channel, the client sends a message of type SUBSCRIBE to the server.

{
  "type": "SUBSCRIBE",
  "data": {
    "channel": "<channel_name>"
  }
}

Publish

To publish a payload to a channel, the client sends a message of type PUBLISH to the server.

{
  "type": "PUBLISH",
  "data": {
    "channel": "<channel_name>",
    "payload": "<payload>"
  }
}

Notification

When a payload is published to a channel, the server sends a message of type NOTIFY to all clients subscribed to that channel.

{
  "type": "NOTIFY",
  "data": {
    "channel": "<channel_name>",
    "payload": "<payload>"
  }
}

Expected behavior

Please note the server is not required to log those exact messages, it's just for you to understand the expected behavior.

Getting started

You only need to implement the websocket server handler. We already provide you with a basic structure for the project, which includes:

  • In cmd/client and cmd/server, the executables for the client and server, already implemented.
  • In pubsub/client.go, a basic implementation for the client. You can modify this file if you want but you don't need to to complete the test.
  • In pubsub/protocol.go, the type definitions for the JSON messages exchanged between the client and the server.
  • In pubsub/handler.go, the HTTP handler for the websocket server. This is where you should implement the server logic.

What do we judge?

  • Correctness: the server should implement the specifications provided above.
  • Code quality: your code should be readable and maintainable.
  • Thread safety: the server should be able to handle multiple clients concurrently without experiencing race conditions.
  • Error handling: the server should handle client disconnections, invalid messages and other error case as gracefully as possible.

Bonus: you can also write tests for your code, but it's not mandatory.

How to send your app code

When you feel you are done, open a Pull Request with your change in this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages