Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added meeting scheduler low level design #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

codeimmortal
Copy link

What this design contains:

  1. Depending of Room capacity , meeting is schedule.
  2. Meeting class use observer pattern to notify all participant.
  3. If Room is booked in certain interval, we can not book at the time other meeting.
  4. for a user there is not restriction, we can schedule multiple meeting at same time.
  5. The design is extendable to get history of room.

@codeimmortal
Copy link
Author

codeimmortal commented Jan 12, 2025

@thesaltree Design is ready for Merge.

@codeimmortal
Copy link
Author

Are we merging this?

@thesaltree
Copy link
Owner

thesaltree commented Jan 27, 2025

@codeimmortal thanks for the PR. Some critical functionalities are missing in the implementation, like:

  • Concurrency is not handled. Multiple users booking rooms simultaneously might lead to race conditions. Please use synchronization mechanisms like sync.Mutex or sync.RWMutex to modify shared data structures like rooms or meeting.
  • Method to query available rooms for a specific time interval before attempting to book is missing.
  • Functionality to cancel a scheduled meeting and free up the corresponding time slot in the room's calendar can be added.

Can you please add these?

@codeimmortal
Copy link
Author

Added mutex , cancelRoom , GetAllFree room functionality.

Comment on lines +48 to +50
if meetingId > len(ms.meeting) {
return errors.New("There is no such meeting")
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeimmortal valid index range is [0, len(ms.meeting)-1]. This should be fixed to:
if meetingId >= len(ms.meeting) || meetingId < 0

users := []*User{
&User{id: 1, name: "sam", email: "sam@email.com"},
&User{id: 2, name: "ron", email: "ron@email.com"},
&User{id: 2, name: "don", email: "don@email.com"},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeimmortal multiple users have the same id=2, which would cause issues in participant management.

name string
status BookingStatus
location location
calender *Calendar
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeimmortal there is inconsistency in naming --> calendar vs calender


// cancel meeting
ms.meeting[meetingId].CancelMeeting()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After canceling a meeting, it remains in ms.meeting, which could cause unnecessary memory usage. We can set ms.meeting[meetingId] = nil

Comment on lines +67 to +81
func (m *MeetingRoom) isFree(dur *interval) bool {
if m.calender.isFree(dur) {
return true
}

return false
}

// IsFree is use to explose outside
func (m *MeetingRoom) IsFree(dur *interval) bool {
m.mu.Lock()
defer m.mu.Unlock()

return m.isFree(dur)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeimmortal this can be refactored to:

func (m *MeetingRoom) IsFree(dur *interval) bool {
	m.mu.Lock()
	defer m.mu.Unlock()

	return m.calender.isFree(dur)
}

@thesaltree
Copy link
Owner

@codeimmortal thanks for addressing the feedback. Can you also add a section for the readme file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants