| Age | Commit message (Collapse) | Author |
|
This release bring many enhancements to lib/websocket including timeout,
handling upgrade and read/write concurrently using goroutine.
=== Breaking changes
* lib/net: changes the WaitRead/Event model on Poll
=== Bug fixes
* lib/websocket: call Quit when handshake contains close or invalid frame
* lib/websocket: revert maxBuffer back to 1024
=== New features
* lib/ascii: add type Set
* lib/net: implement generic PollEvent
=== Enhancements
* lib/websocket: add option to set read/write timeout on Server
* lib/websocket: handle concurrent upgrade using goroutine
* lib/websocket: handle concurrent Server read using goroutines
* lib/websocket: handle concurrent ping using goroutines
=== Chores
* websocket/testdata: rewrite autobahn test using container
|
|
While at it, fix flaky test on DirWatcher due to race condition when
accessing dirKeys.
|
|
In the server, change the listen port to 9101 to prevent conflict
with autobahn test suite.
In the client, add command "chat" and "chatbot".
The "chat" command run client chart as before.
The "chatbot" command create client for all known accounts and send
N messages continuously.
|
|
When the goroutine for upgrade, reader, or pinger does not receive
any input from its queue after N duration, stop it.
Currently, N equal to ServerOptions ReadWriteTimeout.
This allow unused goroutines released back to system, minimizing
resources usage.
|
|
|
|
The maximum goroutines is quarter of max queue.
The new goroutine for pinger will be dispatched when no goroutine can
consume the current processed connection.
|
|
Adding prefix provide better way to locate and debug the error in the
future.
|
|
Previously, the Pool's WaitRead and WaitReadEVent methods return list of
file descriptor (fd) and keeps the fd in the pool.
In case we want to process the returned fd concurrently, by running it
in different goroutine, the next call WaitRead may return the same fd
if its goroutine not fast enought to read from fd.
This changes fix this issue by removing list of fd from poll and set the
fd flag to blocking mode again after returning it from WaitRead or
WaitReadEvent.
This changes also remove the ReregisterRead and ReregisterEvent methods
since it is not applicable anymore.
|
|
The Server now dispatch a goroutine to consume event from poll reader
for each client connection that is ready to read.
The maximum number of goroutine is defined in ServerOptions
maxGoroutineReader, which currently set to 1024.
|
|
The PollEvent contains file descriptor and the underlying event
based on OS, unix.EpollEvent on Linux or unix.Kevent_t on BSD.
The Poll interface provides two APIs to works with PollEvent,
WaitReadEvents that return list of PollEvent ready for read, and
ReregisterEvent to register the event back to poll (only for Linux).
|
|
|
|
The maxGoroutineUpgrader define maximum goroutines running at the same
time to handle client upgrade.
The new goroutine only dispatched when others are full, so it will
run incrementally not all at once.
Default to defServerMaxGoroutineUpgrader (128) if its not set.
|
|
Using directory testdata that contains Go code seems like not good
choices for future improvement, especially if we want to add shared code
that can be imported by server and client later.
|
|
In case the user of poll changes the fd flags to block for reading
or writing and forgot to set it non-block again, this may cause an issue
on the poll.
|
|
The ReadWriteTimeout define the maximum duration the server wait when
receiving/sending packet from/to client before considering the
connection as broken.
Default read-write timeout is 30 seconds if not set.
This changes affect the exported function Send and Recv by adding
additional parameter timeout to both of them.
|
|
Since the autobahn script can only run on Python 2, it become hard to
setup and run the test on distro that does not provide Python 2 anymore.
The autobahn repository recommend to use docker instead.
When testing the server, we simplify it by using make task "test-server".
The test-server task run our test server in background, and then run the
autobahn fuzzingclient from container.
Once the tests completed, we trigger the server to shutdown by sending
text frame with payload "shutdown".
When testing the client, we simplify it by using make task "test-client".
The test-client task run the autobahn fuzzingserver and then
we run our client.
Once client finished, we trigger the server to generate the reports
and cleanup the container.
|
|
In 25d09e2625f we increase the maxBuffer to 4096 to try increasing the
performance when handling large payload.
Turns out increasing this make the server cannot handle larger payload.
|
|
If the HTTP handshake response contains trailing frame, handle it
directly.
If the frame is invalid or control close operation, call Quit directly
to trigger the HandleQuit if its defined by user.
|
|
The unit and benchmark tests are taken from upstream [1], with author
permission on this GitHub comment [2].
[1] https://github.com/elliotwutingfeng/asciiset
[2] https://github.com/shuLhan/share/pull/7#issuecomment-1573271518
|
|
Wu Tingfeng provide ascii.Set type.
|
|
The asciiset.Set type is exported as ascii.Set.
|
|
|
|
The package asciiset add new type ASCIISet, a bitmap to represent list of ASCII characters
for faster lookup.
ASCIISet is a 36-byte value, where each bit in the first 32-bytes represents the presence of
a given ASCII character in the set.
The remaining 4-bytes is a counter for the number of ASCII characters in the set.
The 128-bits of the first 16 bytes, starting with the least-significant bit of the lowest word
to the most-significant bit of the highest word, map to the full range of all 128 ASCII characters.
The 128-bits of the next 16 bytes will be zeroed, ensuring that any non-ASCII character will
be reported as not in the set.
|
|
=== Breaking changes
* email/maildir: major refactoring plus adding unit tests
* lib/email: unexport the field ContentType in the field
=== Bug fixes
* lib/dns: fix zone parsing on SOA record with single line
* lib/memfs: ignore permission error when scanning directory content
* lib/memfs: fix panic when watched file deleted or renamed
* lib/email: fix parsing multiple parameters in ContentType
=== New features
* cmd/bcrypt: CLI to compare or generate hash using bcrypt
* lib/sql: add type DmlKind
* email/maildir: implement Folder
* lib/net: add function WaitAlive
* lib/smtp: implement Client SendEmail
=== Enhancements
* lib/dns: add option to set debug level in ServerOptions
* lib/dns: do not cache empty answers
* _bin/go-test-coverhtml: add parameter to run specific test
* lib/http: redirect path with slash if request is directory
* lib/email: handle obsolete white spaces and comment when unpacking date
* lib/email: set the Field Type and unpack its value on ParseField
* lib/net: increase the maximum poll events
* lib/websocket: increase the max buffer and queue for better throughput
=== Chores
* all: remove any usage of debug.Value in all packages
* lib/test: update documentation related to Assert and Data
* all: record the contributors of this module in file AUTHORS
Signed-off-by: Shulhan <ms@kilabit.info>
|
|
The maxBuffer increased from 1024 to 4096 bytes.
The reason that we use 1024 previously is related to MTU size and maximum
payload in TCP (although its higher, 1460 bytes).
The maxQueue increase from 128 to 4096.
|
|
The maxQueue define the number of events that can be read from poll at
one time.
Using 128 seems to small for high throughput networks.
Increasing this number also increase the memory consumed by process.
Maybe later we can export this function as option when creating poll.
|
|
Mention that some of the commands are example of implementation of the
library.
|
|
|
|
The idea is to allow other contributors to copyright their code while
still referencing the same LICENSE.
|
|
Once the field Name has detected and its Value is valid, we can unpack
the Value based to type that it represent, for example to Date or Mailbox.
This changes remove calling to unpack directly in some tests and check
an error when testing ParseHeader.
|
|
|
|
In the obsolete syntax, white space and comments can appear between many
more element, for example the folloing Date value are valid
Date : Fri, 21 Nov 1997 09(comment): 55 : 06 -0600
This changes handle this by sanitizing the Field value, removing comment
and merge multiple spaces into one, before parsing it.
|
|
|
|
In obsolete syntax for mailbox in Field value, a domain can have space.
For example, the following message-id is valid according to RFC 5322
Section A.6.3:
message-id:<1234 @ local(blah) .machine .example>\r\n
This changes handle this by removing all spaces before validating the
domain name.
|
|
The %q will print the character itself if its printable or an hexadecimal
representation.
|
|
Unlike TrimSpaces, which only remove spaces on beginning and end,
RemoveSpaces remove all spaces including in between characters.
|
|
Split the parsing into two methods: parseName and parseValue.
The error returned from those methods are prefixed by its name.
|
|
The field ContentType will be set only when the field Name is
"Content-Type" so it's not always exist on each field.
To get the field ContentType, use Header.ContentType().
|
|
Somehow in 3a1a2715b25f, we include this method without implementing it.
The SendEmail method simplify sending email by automatically create
[MailTx] for passing it to method Client.MailTx.
The test right now use live connection since the Server is not ready yet.
|
|
This changes rename field,
* listener to listenMta since this is the socket that responsible
receiving message from other Mail Trasnfer Agent (MTA).
* tlsListener to listenSubmission since this is the socket that
responsible receiving message from Mail User Agent (MUA) for submiting
new message.
|
|
Even if LocalHandler and LocalStorage is one of implementation of
Handler and Storage, it is be better if its return the actual type, to
minimize confusion.
|
|
The documentation is based on the article published at
https://kilabit.local/journal/2023/go_test_data/
after reviewing and explain how to use both of them to public.
|
|
This example show expected, got, and diff between them.
|
|
Add an overview of all types as building blocks from top to bottom so
we can see the relation in each of them.
|
|
I am not the authors of those RFCs, only make the summary to make it
simple to understand and to implement.
|
|
The GetParamValue and SetBoundary should match any parameter key in
case insensitive matter.
While at it, add examples for ParseContentType and SetBoundary, and move
test for GetParamValue to Example.
|
|
While at it, also fix the ContentType String method to prefix ';' before
appending parameter key and value.
|
|
This cut the test time to 0.100 second, match with sleep duration.
|
|
WaitAlive try to connect to network at address until timeout reached.
If connection cannot established it will return an error.
Unlike [net.DialTimeout], this function will retry not returning an error
immediately if the address has not ready yet.
|
|
This is to prevent non-exported functions, type, or variables being used
in example.
|