-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This separates out an API for channels that can handle subservices (like http, sockets, etc.) and those that can't (like jsonrpc). Bump the minor version of this so it can be pushed out. Squashed commit of the following: commit 8b80111 Author: Jason Monk <jmonk@dream-crushed.com> Date: Wed Feb 16 20:12:51 2022 -0500 Fix last couple API tweaks and run auto-formatter Also bump the version commit 931fa02 Author: Jason Monk <jmonk@dream-crushed.com> Date: Mon Feb 14 20:35:23 2022 -0500 Allow bidirectional jsonrpc Since LSP operates this way, assuming the protocol generally supports it. commit 6e06e1f Author: Jason Monk <jmonk@dream-crushed.com> Date: Sat Feb 12 10:52:19 2022 -0500 Working json rpc implementation with all the tests passing Need to do some e2e tests to verify before pushing to main commit 796f5ce Author: Jason Monk <monk@fb.com> Date: Mon Jan 10 10:03:58 2022 -0500 WIP Stuff commit 98ebd77 Author: Jason Monk <monk@fb.com> Date: Mon Jan 10 10:03:58 2022 -0500 WIP Stuff
- Loading branch information
1 parent
15def2f
commit bdc5bbf
Showing
30 changed files
with
1,377 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
build/ | ||
local.properties | ||
**/build | ||
**/*.swp | ||
|
||
# Eclipse | ||
.classpath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
version=0.5.0 | ||
version=0.5.1 | ||
plugin_version=0.5.0 | ||
signing.gnupg.keyName=5B83421E2338B907 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2021 Jason Monk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.monkopedia.ksrpc.channels | ||
|
||
import com.monkopedia.ksrpc.KsrpcEnvironment | ||
import com.monkopedia.ksrpc.internal.ThreadSafeManager.threadSafe | ||
import com.monkopedia.ksrpc.internal.jsonrpc.JsonRpcWriterBase | ||
import com.monkopedia.ksrpc.internal.jsonrpc.jsonHeader | ||
import com.monkopedia.ksrpc.internal.jsonrpc.jsonLine | ||
import io.ktor.utils.io.ByteReadChannel | ||
import io.ktor.utils.io.ByteWriteChannel | ||
import kotlinx.coroutines.CoroutineScope | ||
|
||
suspend fun Pair<ByteReadChannel, ByteWriteChannel>.asJsonRpcConnection( | ||
env: KsrpcEnvironment, | ||
includeContentHeaders: Boolean = true | ||
): SingleChannelConnection { | ||
return threadSafe<SingleChannelConnection> { context -> | ||
JsonRpcWriterBase( | ||
CoroutineScope(context), | ||
context, | ||
env, | ||
if (includeContentHeaders) jsonHeader(env) else jsonLine(env) | ||
) | ||
}.also { | ||
(it as? SuspendInit)?.init() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
ksrpc/src/commonMain/kotlin/channels/SingleServiceChannel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2021 Jason Monk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.monkopedia.ksrpc.channels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.