Skip to content

Commit

Permalink
Migrate everything to snailgun
Browse files Browse the repository at this point in the history
  • Loading branch information
jvican committed Jun 27, 2019
1 parent 367cc5f commit aacb0e1
Show file tree
Hide file tree
Showing 31 changed files with 107 additions and 103 deletions.
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sailgun
# Snailgun

Copyright 2019-2020 Jorge Vicente Cantero
Copyright 2019-2020 Scala Center (EPFL)
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# sailgun :sailboat:
# snailgun :snail: :gun:

[![Build Status](https://travis-ci.org/jvican/sailgun.svg?branch=master)](https://travis-ci.org/jvican/sailgun)
![Maven Central](https://img.shields.io/maven-central/v/me.vican.jorge/sailgun-core.svg)
[![Build Status](https://travis-ci.org/jvican/snailgun.svg?branch=master)](https://travis-ci.org/jvican/snailgun)
![Maven Central](https://img.shields.io/maven-central/v/me.vican.jorge/snailgun-core.svg)

Sailgun is a [Nailgun](https://github.com/facebook/nailgun) client written in Scala.
Snailgun is a [Nailgun](https://github.com/facebook/nailgun) client written in Scala.

The goal of sailgun is to be a flexible, cross-platform, zero-dependency
The goal of snailgun is to be a flexible, cross-platform, zero-dependency
Nailgun client that can be used both as a *binary* and as a *library
dependency*.

## Motivation :ocean:
## Motivation 💭

Nailgun is a useful protocol to communicate lightweight, short-lived clients
with long-running servers.
Expand All @@ -18,15 +18,15 @@ Developers have traditionally used Nailgun to communicate native-like clients
with services running on the JVM. However, there are many use cases that
require JVM clients connect to Nailgun servers and those are currently unsupported.

Sailgun is an alternative implementation to the [default Python and C
Snailgun is an alternative implementation to the [default Python and C
clients](https://github.com/facebook/nailgun/tree/master/nailgun-client) of
the Nailgun protocol that intends to be extensible, fast and support
**both** JVM and Native clients.

* It provides a simple API that for any JVM-based programming language.
* It can be compiled to a Native binary that is 10x faster than the Python client through [GraalVM's Native Image][graalvm-native].

Sailgun's major use cases are:
Snailgun's major use cases are:

1. You need a client that talks the Nailgun protocol but you need to customize it.
1. You need to communicate with a Nailgun server implemented in another language.
Expand All @@ -38,25 +38,25 @@ Sailgun's major use cases are:

### Library
The API is meant to be simple and extensible. The
[`sailgun-core`](sailgun-core/) directory that hosts the implementation. The
[`snailgun-core`](snailgun-core/) directory that hosts the implementation. The
entrypoint is `Client` and the full protocol implementation is `Protocol`.


Sailgun is published to Maven Central. Add it to your project with:
Snailgun is published to Maven Central. Add it to your project with:

```scala
libraryDependencies += "me.vican.jorge" %% "sailgun" % "SAILGUN_VERSION"
libraryDependencies += "me.vican.jorge" %% "snailgun" % "SNAILGUN_VERSION"
```

where `SAILGUN_VERSION` is the latest git tag in this repository.
where `SNAILGUN_VERSION` is the latest git tag in this repository.

### Binary

You can generate a Sailgun binary by following the steps described in the
You can generate a Snailgun binary by following the steps described in the
[GraalVM Native Image guide][graalvm-native].

To generate a native binary out of this repository, run
`sailgun-cli/graalvm-native-image:packageBin` in a machine that has GraalVM
`snailgun-cli/graalvm-native-image:packageBin` in a machine that has GraalVM
and `native-image` installed.

[graalvm-native]: https://www.graalvm.org/docs/reference-manual/aot-compilation/
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import build.BuildKeys._
import build.Dependencies

lazy val `sailgun-core` = project
lazy val `snailgun-core` = project
.in(file("core"))
.settings(testSuiteSettings)
.settings(
Expand All @@ -13,9 +13,9 @@ lazy val `sailgun-core` = project
)
)

lazy val `sailgun-cli` = project
lazy val `snailgun-cli` = project
.in(file("cli"))
.dependsOn(`sailgun-core`)
.dependsOn(`snailgun-core`)
.enablePlugins(GraalVMNativeImagePlugin)
.settings(testSuiteSettings)
.settings(
Expand All @@ -30,9 +30,9 @@ lazy val `sailgun-cli` = project
)
)

lazy val sailgun = project
lazy val snailgun = project
.in(file("."))
.aggregate(`sailgun-core`, `sailgun-cli`)
.aggregate(`snailgun-core`, `snailgun-cli`)
.settings(
releaseEarly := { () },
skip in publish := true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package sailgun
package snailgun

import java.io.PrintStream
import java.io.InputStream
import java.util.concurrent.atomic.AtomicBoolean

import sailgun.protocol.Defaults
import sailgun.protocol.Streams
import sailgun.logging.SailgunLogger
import snailgun.protocol.Defaults
import snailgun.protocol.Streams
import snailgun.logging.SnailgunLogger

import scopt.OParser
import java.net.ConnectException
Expand Down Expand Up @@ -87,7 +87,7 @@ abstract class Cli(in: InputStream, out: PrintStream, err: PrintStream) {
else Defaults.env.getOrElse("NAILGUN_PORT", params.nailgunPort.toString).toInt
val client = TcpClient(hostServer, portServer)
val noCancel = new AtomicBoolean(false)
val logger = new SailgunLogger("log", out, isVerbose = params.verbose)
val logger = new SnailgunLogger("log", out, isVerbose = params.verbose)
try {
val code =
client.run(cmd, cmdArgs, Defaults.cwd, Defaults.env, streams, logger, noCancel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sailgun
package snailgun

import sailgun.protocol.Defaults
import snailgun.protocol.Defaults

final case class CliParams(
nailgunServer: String = Defaults.Host,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun;
package snailgun;

import com.sun.jna.Native;
import com.sun.jna.Library;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sailgun
package snailgun

import sailgun.logging.Logger
import sailgun.protocol.Streams
import sailgun.protocol.Defaults
import snailgun.logging.Logger
import snailgun.protocol.Streams
import snailgun.protocol.Defaults

import java.nio.file.Path
import java.util.concurrent.atomic.AtomicBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package sailgun
package snailgun

import sailgun.logging.Logger
import sailgun.logging.SailgunLogger
import sailgun.protocol.Defaults
import sailgun.protocol.Protocol
import sailgun.protocol.Streams
import snailgun.logging.Logger
import snailgun.logging.SnailgunLogger
import snailgun.protocol.Defaults
import snailgun.protocol.Protocol
import snailgun.protocol.Streams

import java.net.Socket
import java.nio.file.Paths
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun.logging
package snailgun.logging

abstract class Logger {
val name: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sailgun.logging
package snailgun.logging

import java.io.PrintStream

class SailgunLogger(
class SnailgunLogger(
override val name: String,
out: PrintStream,
override val isVerbose: Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun.protocol
package snailgun.protocol

import java.io.OutputStream

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun.protocol
package snailgun.protocol

import java.nio.charset.StandardCharsets

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun.protocol
package snailgun.protocol

import java.nio.file.Paths

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sailgun.protocol
package snailgun.protocol

import sailgun.Terminal
import sailgun.logging.Logger
import snailgun.Terminal
import snailgun.logging.Logger

import java.net.Socket
import java.io.OutputStream
Expand Down Expand Up @@ -37,7 +37,7 @@ import scala.util.control.NonFatal
* been simplified more than these two and optimized for readability.
*
* The protocol is designed to be used by different instances of
* [[sailgun.Client]] implementing different communication mechanisms (e.g.
* [[snailgun.Client]] implementing different communication mechanisms (e.g.
* TCP / Unix Domain sockets / Windows Named Pipes).
*/
class Protocol(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sailgun.protocol
package snailgun.protocol

import java.io.InputStream
import java.io.OutputStream
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sailgun.utils;
package snailgun.utils;

public class SailgunArgEcho {
public class SnailgunArgEcho {
public static void main(String[] args) {
/*
boolean isFirst = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/

package sailgun.utils;
package snailgun.utils;

/**
* Echos everything it reads from System.in to System.out.
*
* @author <a href="http://www.martiansoftware.com/contact.html">Marty Lamb</a>
*/
public class SailgunEcho {
public class SnailgunEcho {
public static void main(String[] args) throws Exception {
byte[] b = new byte[1024];
int bytesRead = System.in.read(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/

package sailgun.utils;
package snailgun.utils;

import com.martiansoftware.nailgun.NGContext;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* Print H for each heartbeat received
*/
public class SailgunHeartbeat {
public class SnailgunHeartbeat {

public static void nailMain(final NGContext context) {
long runTimeout = Long.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/

package sailgun.utils;
package snailgun.utils;

/**
* A truly amazing program that must be seen to be believed.
*
* @author <a href="http://www.martiansoftware.com/contact.html">Marty Lamb</a>
*/
public class SailgunHelloWorld {
public class SnailgunHelloWorld {

public static void main(String[] args) {
System.out.println("Hello, world!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
limitations under the License.
*/

package sailgun.utils;
package snailgun.utils;

import com.martiansoftware.nailgun.NGContext;

/** Finish nail with provided exit code */
public class SailgunStatusCode {
public class SnailgunStatusCode {
public static void nailMain(NGContext ctx) {
String[] args = ctx.getArgs();
int exitCode = (int) ((Math.random() * 1000) + 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sailgun
package snailgun

import sailgun.utils.{Diff, DiffAssertions}
import snailgun.utils.{Diff, DiffAssertions}

import scala.concurrent.Await
import scala.concurrent.Future
Expand Down
Loading

0 comments on commit aacb0e1

Please sign in to comment.