-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Reorganize modules to support all targets in pure Kotlin modules #234
Comments
joffrey-bion
changed the title
Reorganize modules to allow all-platform support of pure Kotlin modules
Reorganize modules to support all targets in pure Kotlin modules
Jun 12, 2022
joffrey-bion
added a commit
that referenced
this issue
Jun 13, 2022
joffrey-bion
added a commit
that referenced
this issue
Jun 13, 2022
joffrey-bion
added a commit
that referenced
this issue
Jun 20, 2022
joffrey-bion
added a commit
that referenced
this issue
Jun 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background
Currently the
krossbow-websocket-core
module defines different things:WebSocketClient
,WebSocketConnection
)NSURLSession
on darwin targets)WebSocketClient.Companion.default()
factory function that returns the adapted built-in implementation on each supported targetThe
krossbow-stomp-core
directly depends onkrossbow-websocket-core
(it obviously needs this common API), but also provides a no-argStompClient()
constructor relying on thedefault()
websocket factory function.The problems
Problem 1: Limited platform support
The websocket API part cannot be published for all targets because adding other targets would require providing a default built-in implementation for them as well (due to the
default()
expected function).In turn,
krossbow-stomp-core
cannot support all targets either, even though it is implemented 100% in pure Kotlin, because it depends onkrossbow-websocket-core
. It also has a similar problem because it relies on thedefault()
websocket factory function.One major drawback is that users cannot use any Krossbow module on targets that have no Krossbow built-in ws implementation, even if they want to provide their own implementations for those targets. Worse, they cannot use Ktor websockets on such targets even though Ktor supports them, because we can't release the Ktor Krossbow adapter on those targets due to the absence of Krossbow's websocket API for those targets.
Problem 2: unnecessary classes in 3rd party adapter modules
The built-in adapters from
krossbow-websocket-core
are present inkrossbow-websocket-ktor
and similar modules, even though most of the time they are not used (the point of the other modules is to adapt other things than the platform's built-in clients).The solutions
Extract the multiplatform
default()
factory function along with built-in adapters into a new module. Possible names:krossbow-websocket-default
(emphasis on the fact that there is a multiplatformdefault()
method that provides something sensible on every platform)krossbow-websocket-builtin
(emphasis on the fact that the implementation is built-in the current platform)krossbow-websocket-zerodep
(emphasis on the fact that there is no transitive deps)krossbow-websocket-simple
(because why not?)Extract the no-arg
StompClient()
constructor (which uses the multiplaformWebSocketClient.default()
method) fromkrossbow-stomp-core
into its own module. Possible names:krossbow-stomp-default
(looks like a good default choice, and also provides a "default" constructor)krossbow-stomp-builtin
(hints at the fact that we use built-in implementations of WS from the platform, but unclear for this module)krossbow-stomp-simple
(because why not?)krossbow-stomp
(hints users towards using it by default, but the difference withkrossbow-stomp-core
would be quite unclear)Intermediate source set doesn't cut it
We could declare an intermediate source set like
commonDefault
in bothkrossbow-websocket-core
andkrossbow-stomp-core
to hold the websocketdefault()
factory function and theStompClient()
no arg constructor, respectively. This would neatly bring thedefault()
function to user projects when they have the right subset of targets, and not in projects that need more platforms.Why it's not great:
StompClient()
constructor or theWebSocketClient.default()
factory functionThe text was updated successfully, but these errors were encountered: