Repository for bash-event
This event is to build a chat system (A poor man's IRC)... A basic chat system where each team will develop portion of it using services...
To build a terminal based chat system with only bash scripts. Each team will develop small services using bash scripts which when integrated will produce a basic chatting functionality. Files acts as medium of communication between services.
Each service will receive files as inputs and produce the files as its output.
For example, to request a service to registry service create a file as request_001 and the response would be available as response_001.Every service will have a variable name ${< service_name >_SERVICE_DIRECTORY} where all the requests and response files for that service will created and consumed.
Each team should decide the input and output format for the files that will be processed by the service and it will be shared to other teams who needs your service.
To request a service:
- Contact the service provider(team) for the request file name format, response file name format and the format of file contents.
- Create the request file in the ${< service_name >_SERVICE_DIRECTORY} and monitor for a response in the same directory. Note: Suffix a unique identifier in the file name to identify the request and response.
All the teams are expected to first finalize their input and output formats.
Fill In the Format:
- Request file name format(s): 2, Response file name format(s):
- Request Content format(s):
- Response Content format(s):
Each service will have a service identifier to identify itself. Services are encouraged to have these identifiers part of the file name format when requesting service from other service providers.
Variable ${< service_name >_IDENTIFIER} will be provided and will contain the service identifier assigned to each service.
To request a unique id:
Create a file request_${service_identifier} in ${UNIQUE_ID_SERVICE_DIRECTORY}, Here ${service_identifier} will help to identify the corresponding response to this request.
In addition to printing debug messages to service specific files, the file path available in ${STATUS_REPORT_FILE} should be updated by all the services with INFO|WARNING|ERROR messages.
echo “[< service_name >.< info|warn|error >] ” >> ${STATUS_REPORT_FILE}
This service is used to manage users and their passwords which will be used when checking for user existence, authenticating the user and registering the user and their passwords. The details are maintained in a internal database(perhaps plain text). ${REGISTRY_SERVICE_DIRECTORY} is defined and all requests files created in this directory will be served accordingly.
List of Operations
- ADD_USER
- CHECK_USER_EXISTS
- AUTHENTICATE_USER
- LIST_USERS
ADD_USER:username:password
CHECK_USER:username
LIST_USERS
OK
ERROR_USER_EXISTS
ERROR_NO_USER
This is the core service of this chat system. For each request this service will check the existence of each parties involved and deliver the content in the destination user's mail box. ${MESSAGING_SERVICE_DIRECTORY} is defined and all messaging requests should land here. The messaging service will publish the ${MAIL_BOX_DIRECTORY} variable which will have the mailboxes for users where they can fetch the incoming messages.
List of Operations
- SEND_MESSAGE
${MAIL_BOX_DIRECTORY}//msg1
${MAIL_BOX_DIRECTORY}//msg2
SEND MESSAGE
FROM:
TO:
MSG:
This service adds chat room functionality. The service will monitor the directory in the variable ${ROOM_SERVICE_DIRECTORY}.
This Service will create separate directories for each room and maintain a main chat file in its room directory. For every POST_MESSAGE action, the service will append the contents to the main chat message with the senders identity.
List of Operations
- ADD_ROOM
- LIST_ROOM
- CHECK_ROOM_EXISTS
- POST_MESSAGE
This is the application that will interact with users and speak with other services in the back-end. This can be a basic menu based application where users will be presented with the list of options to interact with the system. All basic operations are listed in the services design diagram.
To start with chat client can have polling mechanism to retrieve the incoming messages and the chat room updates but it can be enhanced in the future.
List of Operations
--User Management
- SIGN_UP
- LOGIN
- LIST_USERS
-- Messaging - CHAT
- SEND_MESSAGE
- READ_MESSAGE
-- Room - CREATE_ROOM
- LIST_ROOM
- SEND_MESSAGE
- ENTER_ROOM
This service is responsible for generating unique identifiers when requested. The returned identifiers will be used in the file names created by other services when requesting and responding to the service requests. ${UNIQUE_ID_SERVICE_DIRECTORY} is defined and any request in this directory will be responded with a unique number. This is to create a unique file name across the chat system.
Note:
- Each service should make sure that they create a unique request file when accessing this service too. Ex: request_<service_id>001, request<service_id>_002.
- If a sequence number is used, then the service should save its state when going for a temporary shut down, So it can recover its previous sequence number when it restarts.
List of Operations
- REQUEST_ID
Since communication is happening via files, it is possible that we might end up in leaking files. A garbage collector service might come in handle in those situations. Any service should register itself with the garbage collector service with the following parameters,
< Service_name >:Timeout:Path
Garbage collector will then look for all files in this path and if they exceed the timeout then this service will delete those files.
List of Operations
- REGISTER_SERVICE
This service give the backup feature to the chat system and can be used to backup files and directories is the system. Any service should register itself with the backup service with the following parameters,
< Service_name >:BackupPeriod:< comma separated file list. >
List of Operations
- REGISTER_SERVICE