pcp


License

License

Categories

Categories

Data
GroupId

GroupId

io.github.idata-shopee
ArtifactId

ArtifactId

pcp_2.12
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

pcp
pcp
Project URL

Project URL

https://github.com/idata-shopee/pcp
Project Organization

Project Organization

io.github.idata-shopee
Source Code Management

Source Code Management

https://github.com/idata-shopee/pcp

Download pcp_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.idata-shopee/pcp_2.12/ -->
<dependency>
    <groupId>io.github.idata-shopee</groupId>
    <artifactId>pcp_2.12</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.idata-shopee/pcp_2.12/
implementation 'io.github.idata-shopee:pcp_2.12:0.1.1'
// https://jarcasting.com/artifacts/io.github.idata-shopee/pcp_2.12/
implementation ("io.github.idata-shopee:pcp_2.12:0.1.1")
'io.github.idata-shopee:pcp_2.12:jar:0.1.1'
<dependency org="io.github.idata-shopee" name="pcp_2.12" rev="0.1.1">
  <artifact name="pcp_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.idata-shopee', module='pcp_2.12', version='0.1.1')
)
libraryDependencies += "io.github.idata-shopee" % "pcp_2.12" % "0.1.1"
[io.github.idata-shopee/pcp_2.12 "0.1.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
io.github.idata-shopee : klog_2.12 jar 0.1.0
io.github.idata-shopee : sjson_2.12 jar 0.1.5

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.1

Project Modules

There are no modules declared in this project.

pcp

A simple Lisp-Style protocol for communication

travis-ci build status

Features

  • lisp style composation

  • function sanbox. User can control every function and detail by providing the sandbox

  • based on json grammer

Quick example

package io.github.free.lock.pcp.example

import io.github.free.lock.pcp.{PcpServer, Sandbox, PcpClient}

case class User(name: String, age: Int)

object Main {
  def main(args: Array[String]) {
    val pcpServer = new PcpServer(
      // define the sandbox
      new Sandbox(
        Map[String, BoxFun](
          // define add function
          "add" -> Sandbox.toSanboxFun((params: List[Any], pcs: PcpServer) => {
            val a = params(0).asInstanceOf[Int]
            val b = params(1).asInstanceOf[Int]
            a + b
          })
        )
      )
    )

    // we can just use json array string
    // output: 3
    pcpServer.execute("""["add", 1, 2]""")

    // we can also use PcpClient, instead of raw string
    val p = new PcpClient()
    // """["add", 1, ["add", 2, 3]]"""
    val command = p.toJson(
      p.call("add", 1, p.call("add", 2, 3))
    )
    // output: 6
    pcpServer.execute(command)
  }
}

Versions

Version
0.1.1
0.1.0