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

Add message size limit #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/mist.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type (
replicators map[uint32]*localSubscriber
internal map[uint32]*localSubscriber
next uint32
size_limit uint32
}

// A Message contains the tags used when subscribing, and the data that is being
Expand All @@ -51,6 +52,7 @@ func New() *Mist {
subscribers: make(map[uint32]*localSubscriber),
replicators: make(map[uint32]*localSubscriber),
internal: make(map[uint32]*localSubscriber),
size_limit: 0,
}
}

Expand All @@ -63,6 +65,10 @@ func (mist *Mist) Publish(tags []string, data string) error {
return nil
}

if mist.size_limit != 0 && uint32(len(data)) > mist.size_limit {
return nil
}

message := Message{
Tags: tags,
Data: data,
Expand Down