Commit Graph
2949 Commits
Author SHA1 Message Date
Ankit Aggarwal 51c59907fb Some random Swiftyness (#66) 2018-03-05 19:22:45 +09:00
Arjun Nayini 5c2d98cd8f Clean up some code style violations. (#76)
Motivation:

Get the code to adhere better to style standards.

Modifications:

Fixed colon violation, unused arg, unneeded initialization,
and spacing nits.

Result:

No behavioral change, only code style changes.
2018-03-05 19:15:54 +09:00
Johannes Weiß 94c21b6043 write/set(integer:) should like read/getInteger have an option as: argument so types can be specified (#82)
Motivation:

Sometimes getting read/getInteger to guess the type correctly can be
annoying and it's handy to just say `as: UInt8.self` or similar. In
other cases it's not as the type is clear from the environment. This now
enables both, just like we already have for `write/set(integer:)`

Modifications:

added an `as: T.Type = T.self` argument which is optional as it has a
default

Result:

easier to use `ByteBuffer` interfaces
2018-03-05 19:01:10 +09:00
Norman Maurer f3d3267977 Correctly update cached addresses for accepted Channels. (#98)
Motivation:

We missed to correctly update the cached remote and local addresses for accepted Channels. Because of this localAddress and remoteAddr always returned nil.

Modifications:

- Update cached addresses when constructing SocketChannel from existing Socket.
- Add testcase

Result:

Fixes [#97].
2018-03-05 18:44:14 +09:00
Ben Cohen 2c1d993978 Rename PriorityQueue's T to Element and iterator to Iterator, avoiding need for typealiases. (#91)
Motivation:

We've found following these conventions in the standard library simplifies
the code significantly if you create a lot of generic types that conform
to the std lib protocols.

Modifications:

Change the placeholder T to Element and remove now-unnecessary typealias.
Switch the name of the iterator to just Iterator, and have it re-use
the outer type's Element placeholder. Remove now-unnecessary typealiases.
Add deprecated typealiases to make this a non-breaking change.

Result:

Should be a non-functional change. Explicit typing outside the PriorityQueue
type would need to change, but there wasn't any.
2018-03-04 08:36:15 -08:00
sun_ 2a9e2d6660 Small cleanup in EventLoop. (#96)
Motivation:
Cleaner code.

Modifications:
Change () throws -> (T) to () throws -> T

Result:
Cleaner code.
2018-03-04 06:58:20 -08:00
Cory Benfield 4afdf9d6ba Correctly validate delayed upgrade. (#92)
Motivation:

The previous delayed upgrade test didn't really validate what it
claimed to be doing: it validated properties of the I/O, which made
it enormously flaky.

Modifications:

Change the tests to check for the presence/absence of the server
upgrade handler, which is a mark of the actual upgrade process.

Result:

Less flaky tests
2018-03-03 14:41:27 -08:00
Tiago Martinho 2a5ad33542 Add Docker installation instructions to README (#81)
Motivation:
Help developers setting up the project.

Modifications:
Add Docker installation instructions to README.

Result:
More complete instructions.
2018-03-03 20:11:06 +09:00
Tanner 5ff6d9ba72 Publicizes variadic / array ChannelPipeline.addHandler methods and moves them from NIOHTTP1 to NIO. (#79) (#79)
Motivation:

The `addHandler` method is useful for creating extensions to add handlers similar to what Swift NIO offers w/ HTTP. For example:

```swift
extension ChannelPipeline {
    func addPostgreSQLClientHandlers(first: Bool = false) -> EventLoopFuture<Void> {
        return addHandlers(PostgreSQLMessageEncoder(), PostgreSQLMessageDecoder(), first: first)
    }
}
```

Result:

Array and variadic accepting `ChannelPipeline.addHandler` methods are now available when importing the NIO module.
2018-03-03 11:03:22 +09:00
Ian Partridge da65c4f629 Define ChannelDuplexHandler as a typealias (#74) 2018-03-03 10:16:39 +09:00
Johannes Weiß b4d2bfc720 default example servers to use as many threads as cores (#78)
Motivation:

Our example servers used an arbitrary number of threads (the http one
just 1 :|) but `System.coreCount` is a much better default and also
demoes that API.

Modifications:

Changed the example servers to use `System.coreCount` threads.

Result:

Use more of the hardware you paid for.
2018-03-03 10:09:41 +09:00
Cory Benfield f3f37af4ae Support enumerating network interfaces. (#47)
Motivation:

When writing programs that use networks, particularly if you want to
perform multicast joins, it's extremely important to be able to query
network interfaces and get results.

Modifications:

Add support for querying interfaces using getifaddrs and wrap those query
results in a Swift class.

Result:

Users will be able to enumerate the interfaces on their machine.
2018-03-03 09:04:57 +09:00
Bas Broek 16cf264d26 Move GitHub files to .github folder (#71)
* Move GitHub files to .github folder

* Move CONTRIBUTING to root
2018-03-03 07:19:40 +09:00
Bas Broek ab37e31c4d Add syntax highlighting to README (#72) 2018-03-02 22:29:26 +09:00
Ian Partridge cb62f14df3 Add Package.resolved to .gitignore (#73) 2018-03-02 22:21:20 +09:00
Ian Partridge 1167841b6f typo: ChannnelDuplexHandler should be ChannelDuplexHandler (#69) 2018-03-02 21:56:33 +09:00
Cory Benfield 898c2f5882 Update test generation script to append newline character. (#70)
Motivation:

Nicely written files end in newline characters.

Modifications:

Edited the test generation script to put a newline at the end of the
LinuxMain.swift file.

Result:

One more newline
2018-03-02 17:51:20 +09:00
Johannes Weiß 7402483b8d fix EventLoop-hopping thens (#51) (#63)
Motivation:

Previously if we'd futureOnEL1.then { ... in futureInEL2 } we'd forget
to hop from EL1 to EL2 which is bad. Shout out to @tanner0101 for
reporting!

Modifications:

Hop from one EventLoop to another if needed.

Result:

thens between Futures of different EventLoops now correctly switch
EventLoops.
2018-03-02 17:51:03 +09:00
adamnemecek 0bbed6d72f * removed trailing whitespace (#52) 2018-03-02 15:40:52 +09:00
Andrew Bennett 85131d6235 Add example links (#64)
* Add example links to README
2018-03-02 15:30:37 +09:00
Norman Maurer 613998ba9e Add ChannelDuplexHandler protocol (#65)
Motivation:

Sometimes a user needs to implement ChannelInboundHandler and ChannelOutboundHandler. We should remove some of the "boilerplate" code for doing so.

Modifications:

- Add ChannelDuplexHandler and use it.

Result:

Less boilerplate code.
2018-03-02 14:52:42 +09:00
Cory Benfield f10840e297 Fix flaky upgrade test. (#45)
Motivation:

The upgrade test would race with itself and occasionally fail.

Modifications:

Give enough time for all the work to settle before closing the
client channel.

Result:

No more flaky tests.
2018-03-02 11:21:04 +09:00
Tanner 65641b9f9d add NIOFoundationCompat lib to package products (#57) 2018-03-02 10:52:07 +09:00
Wilson Ding a7b1c50d9a fix: typos in README (#58) 2018-03-02 10:32:55 +09:00
Johannes Weiß 1be5c9201f Added PULL_REQUEST_TEMPLATE.md (#49)
Motivation:

It's great if the new pull request dialog comes prefilled so the creator
gets an idea about what we'd like to know.

Modifications:

Added a PR template.

Result:

Hopefully better PR messages.
2018-03-02 10:29:47 +09:00
Sebastian Thiebaud 4cfbbee94a Fix typo for Bootstrap’s resolver parameter (#53) 2018-03-02 10:12:32 +09:00
Moritz Lang c7fd97da81 Update README to consistently use plurals (#56) 2018-03-02 10:10:04 +09:00
Ian Partridge ab26840de4 typo: README.md (#50) 2018-03-02 08:27:12 +09:00
Johannes Weiß 389a6f8489 Added ISSUE_TEMPLATE.md (#48)
Motivation:

It's great if the GitHub issues come prefilled with a template.

Modifications:

Added a template very similiar to the commit one but md.

Result:

hopefully issues that are easier to action :)
2018-03-02 07:46:34 +09:00
Johannes Weiß b81ae9a4b0 fix zero capacity ByteBuffer reallocs (#44)
Motivation:

We'd go into an infinite loop when trying to increase the capacity of a
0 capacity ByteBuffer *doh*. Thanks @vlm for reporting and writing the
test.

Modifications:

made sure ensureAvailableCapacity returns at least 1 if we don't have
enough capacity available.

Result:

0 capacity ByteBuffers resize now.
2018-03-01 17:55:28 +09:00
Kyle Bashour 5a9a16f5b1 Fix typo in README (#46) 2018-03-01 07:13:56 +00:00
Johannes Weiß 4fb0cc68fe fix readme dependencies (#42) 1.0.0 2018-02-28 13:39:11 +00:00
Johannes Weiß 8684fdf00f Use https for dependency so no SSH login is needed. (#40)
Motivation:

We should just use https for our dependency so the user not need to have a github user at all and no ssh configured.

Modifications:

Just use https

Result:

Easier to use and consume SwiftNIO
2018-02-28 13:27:47 +00:00
Norman Maurer ee6cfcf9cf Add FileDescriptor protocol and implement it for FileHandle / BaseSocket (#38)
Motivation:

FileHandle and BaseSocket should implement a common protocol as these are both "based" on file descriptors

Modifications:

- Add FileDescriptor protocol
- Implement it for FileHandler and BaseSocket

Result:

Better code structure
2018-02-28 09:46:29 +00:00
Norman Maurer d74dda7439 Remove Channel.open and rename Selectable.open to isOpen (#19)
Motivation:

Channel.open was not really needed as for our use-case Selectable already provides everything we need. Also how we used Channel.open in some scenarios was not really correct.

Modifications:

- Remove extension method.
- Rename property
- Remove out-dated comment.
- Fix usage of open

Result:

More clear and correct API
2018-02-27 09:34:26 +09:00
Norman Maurer d2bd75328b Fix test code on linux (#37)
Motivation:

73a805c7f6 did some changes but missed to rename one variable. This broke the build on linux.

Modifications:

Rename fn to body.

Result:

Builds again on linux.
2018-02-27 07:36:23 +09:00
Johannes Weiß 73a805c7f6 minor stylistic improvements (#36)
Motivation:

Sometimes we deviated from the style the Swift stdlib sets out for no
reason.

Modifications:

Fixed some stylistic deviations.

Result:

Looks more Swift-like.
2018-02-26 15:52:49 +00:00
Norman Maurer 580924909d Add Selectable.withUnsafeFileDescriptor and use it through the code. (#28)
Motivation:

We missed to check if the file descriptor is still open in ServerSocket before we act on it. We can remove a lot of complexity by just providing a withUnsafeFileDescriptor which will do this for us and use it through out the code-base.

Modifications:

Introduce withUnsafeFileDescriptor and use it to ensure we always only act on open Selectables.

Result:

More correct code.
2018-02-26 11:30:37 +00:00
tomer doron 9652984b60 prepare ci scripts (#32)
Motivation:

set up continuous integration

Modifications:

* update docker file to include all dependencies required for build, unit tests, integration tests and doc generation
* remove dependency steps from doc generation script
* add integration tests driver script

Result:

able to set up docker based continuous integration
2018-02-26 11:27:53 +00:00
Norman Maurer 0797b5c293 EmbeddedChannel should call fireChannelRegistered(...) when register(...) is called. (#34)
Motivation:

At the moment EmbeddedChannel calls fireChannelRegistered() when connect(...) is called. This is not correct, as it should be done when register(...) is called.

Modifications:

- Correctly call `fireChannelRegistered(...)` when register(...) is called
- Simplify init of EmbeddedChannel
- Fix EmbeddedChannelTest

Result:

Correct invocation of methods.
2018-02-26 10:57:07 +00:00
Norman Maurer 21065ed8f0 Revisit access levels and remove return (#35)
Motivation:

We sometimes used internal / public where fileprivate should have been used. Also we used a few return statements which were not needed.

Modifications:

Cleanup access levels and remove return.

Result:

Cleaner code
2018-02-26 09:58:22 +00:00
Norman Maurer 02c573a505 Fix ChannelLifecycleHandler lifecycle recording (#33)
Motivation:

ChannelLifecycleHandler should record .registered as lifecycle in channelRegistered and not .inactive

Modification:

- Correct record .registered
- Fix tests

Result:

Correctly record lifecycle state.
2018-02-26 09:52:39 +00:00
Norman Maurer 65d47a1ac1 Clarification in *Bootstrap docs. (#31)
Motivation:

Some of the docs for *Bootstrap could use some clarification. Also code examples were not formatted as such via markdown.

Modifications:

- Clarify docs
- Use code highlighting via markdown.

Result:

Better docs.
2018-02-26 09:51:03 +00:00
Norman Maurer b4456fbac4 Replace precondition with assert when checks for an implementation bug. (#30)
Motivation:

We used precondition for a few cases where it really checks for our own implementation. We should use assert here as there is nothing the user really can do to trigger it.

Modifications:

Replace precondition with assert.

Result:

Less overhead when in release mode and more correct in general.
2018-02-26 09:49:43 +00:00
Norman Maurer d41c528b68 Add docs for BaseSocket, Socket and ServerSocket. (#27)
Motivation:

Our *Socket classes did not have any docs.

Modification:

Add docs.

Result:

More documentation.
2018-02-23 17:04:53 +00:00
Norman Maurer c7eab7f0b9 We should assert that the BaseSocket was closed when deinit() is called. (#26)
Motivation:

Leaking a fd is bad we should at least assert that we not do.

Modifications:

Add assert in deinit so we crash in debug mode if we leak a socket.

Result:

Code is more robust.
2018-02-23 12:15:35 +00:00
Cory Benfield a779d2f084 Remove the promise-handling from the PWM. (#25)
Motivation:

We no longer have flush promises, so the PWM no longer needs to
handle them.

Modifications:

Removed all flush promise handling from the PWM and associated
tests.

Result:

Less code, more clarity.
2018-02-23 13:13:50 +01:00
Cory Benfield 369a0714ae Remove management of flush promises from PDWM. (#24)
Motivation:

A substantial chunk of code complexity exists in the PDWM to manage
flush promises. This complexity is no longer justified now that we
don't bother with them.

Modifications:

Removed much of the complexity of the PDWM handling of flush promises.

Result:

Simpler, easier to understand code.
2018-02-23 13:09:00 +01:00
Norman Maurer c95051db78 Make WriteBufferWaterMark be a struct and validate low and high watermarks. (#21)
Motivation:

We used Range for WriteBufferWaterMark which did not do any validation of the low and high marks.

Modifications:

Make WriteBufferWaterMark a struct and validate low and high values

Result:

More correct impl for watermarks.
2018-02-23 09:52:30 +00:00
Norman Maurer 49270cc761 Fix docker-compose docs for running the tests (#22)
Motivation:

We missed the "up" argument in our docs.

Modifications:

Fix doc about running tests via docker-compose.

Result:

More correct docs.
2018-02-23 09:35:06 +00:00