-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ralph Gasser <[email protected]>
- Loading branch information
1 parent
1f0d2f0
commit e483891
Showing
4 changed files
with
50 additions
and
67 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...e/src/main/kotlin/org/vitrivr/engine/module/torchserve/client/AbstractTorchServeClient.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,34 @@ | ||
package org.vitrivr.engine.module.torchserve.client | ||
|
||
import com.google.auth.oauth2.AccessToken | ||
import com.google.auth.oauth2.OAuth2Credentials | ||
import io.grpc.Grpc | ||
import io.grpc.InsecureChannelCredentials | ||
import io.grpc.ManagedChannel | ||
import io.grpc.auth.MoreCallCredentials | ||
import java.io.Closeable | ||
import java.util.* | ||
|
||
/** | ||
* An abstract client for connecting to a TorchServe instance via gRPC | ||
* | ||
* @author Ralph Gasser | ||
* @version 1.0.0 | ||
*/ | ||
abstract class AbstractTorchServeClient(val host: String, val port: Int = 8080, private val token: String? = null) : Closeable { | ||
|
||
/** Credentials used for connecting to TorchServe. */ | ||
protected val credentials = this.token?.let { | ||
MoreCallCredentials.from(OAuth2Credentials.create(AccessToken(it, Date(Long.MAX_VALUE)))) | ||
} | ||
|
||
/** The [ManagedChannel] used for gRPC communication. */ | ||
protected val channel: ManagedChannel by lazy { Grpc.newChannelBuilderForAddress(this.host, this.port, InsecureChannelCredentials.create()).build() } | ||
|
||
/** | ||
* Closes this [AbstractTorchServeClient]. | ||
*/ | ||
override fun close() { | ||
this.channel.shutdownNow() | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
...e-torchserve/src/main/kotlin/org/vitrivr/engine/module/torchserve/client/FeatureClient.kt
This file was deleted.
Oops, something went wrong.
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