Server.resource
Owns a Java client, with one to four simultaneous facade calls. Release cancels queued and running operations before closing the client.
Source and package
- Qualified name
-
io.github .libtmux .scaladsl .cats .Server. resource - Package
- io.github.libtmux.scaladsl.cats
- Declared in
Server- Distribution
- io.github.libtmux:libtmux-scala_3
- Source
- libtmux-scala-cats/src/main/scala/io/github/libtmux/scaladsl/cats/Server.scala
-
- Type parameters
- Parameters
-
-
Default
4
Examples
Connect to a private tmux server. Use JDK 25, Gradle 9 or newer, and tmux 3.3a or newer on Linux, with
/bin/catand/bin/shavailable. In an empty directory, save this consumer setup assettings.gradle.kts:rootProject.name = "api-example"Save this consumer setup as
build.gradle.kts. It depends on the 0.1.2 release from Maven Central:plugins {scalaapplication}repositories { mavenCentral() }dependencies {implementation("io.github.libtmux:libtmux-scala-cats_3:0.1.2")implementation("org.scala-lang:scala3-library_3:3.9.0")}java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }application { mainClass.set(providers.gradleProperty("exampleMain")) }Save this consumer setup as
gradle.properties: View sourcegradle.properties org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8kotlin.daemon.jvmargs=-Xmx2gorg.gradle.workers.max=2Save this complete program as
src/main/scala/Connect.scala. It starts a private tmux server of its own and stops it when the program closes it. View sourcesrc/main/scala/Connect.scalaComplete program package io.github.libtmux.examples.api.scalacatsimport io.github.libtmux.scaladsl.cats.*import _root_.cats.effect.{ExitCode, IO, IOApp}import _root_.cats.syntax.all.*/** Connect to a private tmux server. */object Connect extends IOApp {def run(args: List[String]): IO[ExitCode] = {val program = Server.start[IO]().use { server =>for {alive <- server.isAlive()_ <- IO.println(s"connected=$alive")} yield ()}program.as(ExitCode.Success).handleErrorWith { error =>IO(System.err.println("Example failed: " + error.getMessage)).as(ExitCode.Error)}}}Build the minimal consumer with Gradle and run the saved program. An operation or cleanup error makes the command exit unsuccessfully:
Terminal window $ gradle --console=plain --quiet installDist -PexampleMain=io.github.libtmux.examples.api.scalacats.Connect && \build/install/api-example/bin/api-exampleExpected output:
connected=true
Recorded calls
source callsThe Scala reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls io.github.libtmux.scaladsl.cats.Server.resource.
Guides
task materialPages that discuss resource.