-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Mercap/package_splitting
Package splitting
- Loading branch information
Showing
45 changed files
with
271 additions
and
177 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
*.st linguist-language=Smalltalk |
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,15 +1,15 @@ | ||
SmalltalkCISpec { | ||
#loading : [ | ||
SCIMetacelloLoadSpec { | ||
#baseline : 'JRPC', | ||
#directory : 'src', | ||
#platforms : [ #pharo ] | ||
} | ||
], | ||
#testing : { | ||
#categories : [ 'JRPC-Tests' ], | ||
#coverage : { | ||
#categories : [ 'JRPC-Tests' ] | ||
#loading : [ | ||
SCIMetacelloLoadSpec { | ||
#baseline : 'JRPC', | ||
#directory : 'src', | ||
#load : [ 'CI' ], | ||
#platforms : [ #pharo ] | ||
} | ||
], | ||
#testing : { | ||
#coverage : { | ||
#packages : [ 'JRPC-Client' , 'JRPC-Server' , 'JRPC-Tests' ] | ||
} | ||
} | ||
} |
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,31 @@ | ||
Contributing | ||
============ | ||
|
||
There's several ways to contribute to the project: reporting bugs, sending feedback, proposing ideas for new features, fixing or adding documentation, promoting the project, or even contributing code. | ||
|
||
## Reporting issues | ||
|
||
You can report issues [here](https://github.com/juliendelplanque/JRPC/issues/new) | ||
|
||
## Contributing Code | ||
- This project is MIT licensed, so any code contribution MUST be under the same license. | ||
- This project uses [Semantic Versioning](http://semver.org/), so keep it in mind when you make backwards-incompatible changes. If some backwards incompatible change is made the major version MUST be increased. | ||
- The source code is hosted in this repository using the Tonel format in the `src` folder. | ||
- The `master` branch contains the latest changes. | ||
- Feel free to send pull requests or fork the project. | ||
|
||
### Using Iceberg | ||
1. Download a [Pharo Image and VM](https://get.pharo.org/64) | ||
2. Clone the project or your fork using Iceberg | ||
3. Open the Working Copy and using the contextual menu select `Metacello -> Install baseline...` | ||
4. Input `Development` | ||
5. This will load the base code and the test cases | ||
6. Create a new branch to host your code changes | ||
7. Do the changes | ||
8. Run the test cases | ||
9. Commit and push your changes to the branch using the Iceberg UI | ||
10. Create a Pull Request against the `master` branch | ||
|
||
## Contributing documentation | ||
|
||
The project documentation is maintained in this repository in the `docs` folder. To contribute some documentation or improve the existing, feel free to create a branch or fork this repository, make your changes and send a pull request. |
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,90 @@ | ||
# Examples | ||
## Client | ||
Given a server using HTTP protocol, listening on port 4000 and exposing `'sqrt'` method which computes the square-root of its single parameter, one can write the following: | ||
|
||
```Smalltalk | ||
(JRPCClient http: 'http://localhost:4000') | ||
callMethod: 'sqrt' arguments: #(4) withId: 1 | ||
``` | ||
|
||
The object returned by this expression is an instance of `JRPCSuccessResponseObject`. | ||
Its `result` instance variable contains the result of `sqrt` method applied on `4`. That is to say, it contains `2.0`. | ||
Its `id` instance variable contains the `id` specified previously. | ||
|
||
Ids allow to map responses returned by the server to requests sent by the client. | ||
Ids are managed by the developer using the client. | ||
|
||
## Server | ||
To create a server using HTTP protocol, listening on port 4000 and defining an handler for `'sqrt'` which computes the square-root of its single paramter, one can write the following: | ||
|
||
```Smalltalk | ||
server := JRPCServer http | ||
port: 4000; | ||
addHandlerNamed: 'sqrt' block: [ :x | x sqrt ]; | ||
yourself. | ||
``` | ||
|
||
To start it, use `#start` method: | ||
|
||
```Smalltalk | ||
server start | ||
``` | ||
|
||
To stop it, use `#stop` method: | ||
|
||
```Smalltalk | ||
server stop | ||
``` | ||
|
||
## Additional data provided in error messages | ||
[JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification) specifies that in error messages, a `data` field can optionally be set to provide additional information about the error. However, this field structure is specified by the server. This section describes what the current implementation stores in the `data` field. | ||
|
||
To do that, let's take the following configuration. We have a server defined as follow: | ||
```Smalltalk | ||
server := JRPCServer http | ||
port: 4000; | ||
addHandlerNamed: 'divide' block: [ :x :y | x / y ]; | ||
yourself. | ||
server start. | ||
``` | ||
|
||
This server has a handler implenting a the division of `x` by `y`. In Pharo, dividing a `Number` by `0` results in a `ZeroDivide` error. Thus, the following code: | ||
|
||
```Smalltalk | ||
(JRPCClient http: 'http://localhost:4000') | ||
callMethod: 'divide' arguments: #(1 0) withId: 1. | ||
``` | ||
|
||
Will results in a JSON-RPC error for which the error looks like this in JSON format: | ||
|
||
```Smalltalk | ||
{ | ||
"jsonrpc" : "2.0", | ||
"id" : 1, | ||
"error" : { | ||
"data" : { | ||
"tag" : "", | ||
"errorClass" : "ZeroDivide", | ||
"signalerContext" : "SmallInteger>>/", | ||
"messageText" : "", | ||
"signaler" : "1" | ||
}, | ||
"message" : "Internal JSON-RPC error.", | ||
"code" : -32603 | ||
} | ||
} | ||
``` | ||
|
||
Mind the `data` sub-field inside `error` error field. It contains additional data about the error for which the structure is defined by this particular implementation. | ||
|
||
The structure is the following: | ||
``` | ||
{ | ||
"errorClass" : String, // The class of the Pharo error. | ||
"signaler" : String, // The object to which the message was sent when the error occured. | ||
"signalerContext" : String, // The method in which error was raised formatted as Class>>method | ||
"messageText" : String, // The message the Pharo error hold. | ||
"tag" : String // The tag of the Pharo error. | ||
} | ||
``` |
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,46 @@ | ||
# Installation | ||
|
||
## Basic Installation | ||
|
||
You can load **JRPC** evaluating: | ||
```smalltalk | ||
Metacello new | ||
baseline: 'JRPC'; | ||
repository: 'github://juliendelplanque/JRPC:master/src'; | ||
load. | ||
``` | ||
> Change `master` to some released version if you want a pinned version | ||
## Using as dependency | ||
|
||
In order to include **JRPC** as part of your project, you should reference the package in your product baseline: | ||
|
||
```smalltalk | ||
setUpDependencies: spec | ||
spec | ||
baseline: 'JRPC' | ||
with: [ spec | ||
repository: 'github://juliendelplanque/JRPC:v{XX}/src'; | ||
loads: #('Deployment') ]; | ||
import: 'JRPC'. | ||
``` | ||
> Replace `{XX}` with the version you want to depend on | ||
```smalltalk | ||
baseline: spec | ||
<baseline> | ||
spec | ||
for: #common | ||
do: [ self setUpDependencies: spec. | ||
spec package: 'My-Package' with: [ spec requires: #('JRPC') ] ] | ||
``` | ||
|
||
## Provided groups | ||
- `Server-Deployment` will load all the packages needed to deploy a JSON RPC Server | ||
- `Client-Deployemnt` will load all the packages needed to deploy a JSON RPC Client | ||
- `Deployment` will load all the packages needed to deploy both a JSON RPC Client and Server | ||
- `Tests` will load the test cases | ||
- `CI` is the group loaded in the continuous integration setup | ||
- `Development` will load all the needed packages to develop and contribute to the project |
Oops, something went wrong.