Skip to content

ErnestK/grpc_chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Examples of 1 usecase you caould find in log/log.txt

all commands

can run all cli commands from bin or from source

Example

go run cmd/server/main.go or ./bin/client

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=connect or ./bin/client --address=localhost:50051 --user=Alice --op=connect

run server in seprate tab

go run cmd/server/main.go

connect in seprate tab

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=connect

all others in different tab

create group

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=create --target=CoolChat --type=GROUP

join to chat

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=join --target=CoolChat

send message to chat

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=send --target=CoolChat --type=GROUP --msg="Hello everyone in CoolChat!"

list available channels

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=list

leave channel

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=leave --target=CoolChat

Usecases

1) get history

1.1) Run server

go run cmd/server/main.go

1.2) In tab 2 conect as Alice

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=connect

1.3) In tab 3 conect as Bob

go run cmd/client/main.go --address=localhost:50051 --user=Bob --op=connect

1.4) In tab 4

Create group as Alice go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=create --target=CoolChat --type=GROUP

1.5) In tab 4

Sent message as Alice go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=send --target=CoolChat --type=GROUP --msg="Hello everyone in Cool"

1.6) In tab 4

join group as Bob go run cmd/client/main.go --address=localhost:50051 --user=Bob --op=join --target=CoolChat

Result:

in tab 3 Bob get all history messages

2) Broadcasting

2.1) repeat steps from 1 usecase until 1.4( include 1.4 )

2.2) In tab 4

join group as Bob go run cmd/client/main.go --address=localhost:50051 --user=Bob --op=join --target=CoolChat

2.3) In tab 4

Sent message as Alice go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=send --target=CoolChat --type=GROUP --msg="Hello everyone in Cool"

Result:

in tab 2 and in tab 3 all participants( Bob and Alice ), got message.

3) List channel

3.1) repeat steps from 1 usecase until 1.4( include 1.4 )

3.2) List all channels as Alice

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=list

Result:

show list of all channels

4) Send message to other user

4.1) repeat steps from 1 usecase until 1.4( include 1.4 )

4.2) Sent message as Alice to Bob

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=send --target=Bob --type=USER --msg="Hello Bob"

Result:

message appeared to Bob connect(tab 3) tab.

5) Send message to non exist user

5.1) repeat steps from 1 usecase until 1.4( include 1.4 )

5.2) Sent message as Alice to Wally

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=send --target=Wally --type=USER --msg="Hello Bob"

Result:

rpc error: code = Unknown desc = user Wally doesn't exist

6) Leave channel

6.1) repeat steps from 1 usecase until 1.4( include 1.4 )

6.2) List all channel as Alice, CoolChat exists

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=list

6.3) Leave CoolChat as Alice

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=leave --target=CoolChat

6.4) List all channel as Alice, dont(!) CoolChat exists

go run cmd/client/main.go --address=localhost:50051 --user=Alice --op=list

Future improvements

Since I only have one day to develop and implementation rules are limited then the implementation turned out to be more for familiarization and presentation than for use in production.

Also dont have time for tests.

It doesn't handle several real-world scenarios, such as:

  • Authentication of users
  • Dockerization
  • Persistence of data
  • Proper error codes for gRPC responses
  • More advanced concurrency and channel management (e.g., using context for cancellation)
  • Monitoring
  • Reconnection logic for clients
  • Efficient broadcasting algorithms, especially for large-scale systems

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages