Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/trigger.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: "Trigger"

on:
push:
branches:
Expand Down
6 changes: 3 additions & 3 deletions .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"MD033": false,
"MD045": false,
"MD024": {
"siblings_only": true,
"allow_different_nesting": true
}
"siblings_only": true
},
"MD046": false
}
2 changes: 1 addition & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ DISABLE:
- CSS
- DOCKERFILE
- REPOSITORY
# - SPELL # Uncomment to disable checks of spelling mistakes
- SPELL # Uncomment to disable checks of spelling mistakes
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
Expand Down
8 changes: 1 addition & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ fail_fast: true
default_stages: [commit, push]
repos:
- repo: https://github.com/oxsecurity/megalinter
rev: v7.13.0 # Git tag specifying the hook, not mega-linter-runner, version
rev: v8.0.0 # Git tag specifying the hook, not mega-linter-runner, version
hooks:
- id: megalinter-incremental # Faster, less thorough
stages:
- commit
args:
- mega-linter-runner
- --containername=megalinter-incremental
- --flavor=documentation
- --remove-container
- --fix
# npx mega-linter-runner -e 'ENABLE=MARKDOWN,YAML' -e 'SHOW_ELAPSED_TIME=true' -e "'APPLY_FIXES=all'" -e "'CLEAR_REPORT_FOLDER=true'" -e "'LOG_LEVEL=warning'" --containername megalinter-incremental --remove-container --fix --filesonly
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
###############################################################

# build highlight jolie highlight.js
FROM node:alpine AS highlight-jolie
FROM node:20-alpine AS highlight-jolie
WORKDIR /highlight-jolie
COPY highlight-jolie .
RUN npm install
RUN npm run build
RUN npm run build --verbose

# install mdbook
FROM rust:1.65 AS builder
ENV MDBOOK_VERSION="0.4.21"
FROM rust:1.80 AS builder
ENV MDBOOK_VERSION="0.4.40"
ENV ARC="x86_64-unknown-linux-musl"
RUN apt-get update && \
apt-get install --no-install-recommends -y \
musl-tools
RUN rustup target add "${ARC}"
RUN cargo --version
# RUN cargo install mdbook
RUN cargo install mdbook --version "${MDBOOK_VERSION}" --target "${ARC}"
RUN cargo install mdbook --version "${MDBOOK_VERSION}" --target "${ARC}" --locked
# RUN cargo install mdbook-mermaid
RUN cargo install mdbook-mermaid --target "${ARC}"

Expand Down
6 changes: 4 additions & 2 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ command = "mdbook-mermaid"

[output.html]
additional-js = ["src/assets/js/mermaid.min.js", "src/assets/js/mermaid-init.js"]
edit-url-template = "https://github.com/jolie/docs/edit/v1.12.x/{path}"

[output.html.font]
enable = true
woff = true

# [output.html.fold]
# enable = true
[output.html.fold]
enable = true # whether or not to enable section folding
level = 1 # the depth to start folding
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [JSON files](tutorials/standard-library/files/json/README.md)
- [XML files](tutorials/standard-library/files/xml/README.md)
- [Building a File Uploader Service](tutorials/file-uploader/README.md)
- [Scheduler](tutorials/standard-library/scheduler/README.md)
- [Integration Scenarios](tutorials/twitter-api/README.md)
- [Twitter API](tutorials/twitter-api/README.md)
- [Advanced Scenarios](tutorials/advanced-scenarios/supporting-new-protocols-in-jolie/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ As an example let us consider the case of a calculator which offers the four ari

```jolie
from runtime import Runtime
from OperationInterface import OperationInterface
from CalculatorInterface import CalculatorInterface
from .OperationInterface import OperationInterface
from .CalculatorInterface import CalculatorInterface


service Calculator {
Expand Down
8 changes: 7 additions & 1 deletion src/language-tools-and-standard-library/rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ RequestResponse:
listUsers( ListUsersRequest )( ListUsersResponse ),
viewUser( UserRequest )( User ) throws UserNotFound( string ),
updateUser( UserWithUsername )( void ) throws UserNotFound( string ),
deleteUser( UserRequest )( void ) throws UserNotFound( string )
deleteUser( UserRequest )( void ) throws UserNotFound( string ),
default( undefined )( string )
}

service App {
Expand Down Expand Up @@ -74,6 +75,7 @@ service App {
statusCodes.UserNotFound = 404
}
}
default = "default"
}
interfaces: UsersInterface
}
Expand Down Expand Up @@ -134,6 +136,8 @@ service App {
throw( UserNotFound, request.username )
}
} ]

[ default( )( "API listens under /api/user/..." ) ]
}
}
```
Expand All @@ -144,6 +148,8 @@ For example, operation `viewUser` is configured to use:
- `/api/user` as URI template, by `template = "/api/user"`. See the [official RFC on URI templates](https://www.rfc-editor.org/rfc/rfc6570) for more information about them.
- GET as HTTP method, by `method = "get"`.

The `default` operation (optional) gets called when no operation matches to avoid getting HTTP 500 status codes.

## Adding a router

Following this approach, a specific http router, called _jester_, is introduced between the caller and the Jolie service to expose as a REST service. The http router is in charge to convert all the rest calls into the corresponding Jolie operations.
Expand Down
14 changes: 7 additions & 7 deletions src/tutorials/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,30 @@ Some interesting things to note:

* in Jolie there are basic data types as integers, string, double, etc. In the example we exploit `int` (integers) for all the operations with the exception of operations multiplication and division where we use type `double`. You can check the other basic types [here](../../language-tools-and-standard-library/basics/interfaces/data_types/README.md);
* the keyword `type` allows for the definition of structured data types;
* an operation message type is just a data type associated with it into the definition of the operation. As an example the request message of operation `sum` is `SumRequest` whereas the reply is just a `double`;
* an operation message type is just a data type associated with it into the definition of the operation. As an example the request message of operation `sum` is `SumRequest` whereas the reply is just a `int`;
* a data type structure in Jolie represents a tree of nodes. As an example, type `DivRequest` contains two subnodes named `dividend` and `divisor` respectively. Both of them are `double`;
* a node in a data structure can be a vector. As an example node `term` of type `SumRequest` is a vector of `double`. `[1,*]` stands for: minimum occurrences 1 and maximum occurrences infinite. We read `term[1,*]:double` as an unbounded vector of double with at least one element;
* a node in a data structure can be a vector. As an example node `term` of type `SumRequest` is a vector of `int`. `[1,*]` stands for: minimum occurrences 1 and maximum occurrences infinite. We read `term[1,*]:int` as an unbounded vector of int with at least one element;

## Program and run a service

Once we have defined the interface to implement, we are ready to define the service. Let's call the service `CalculatorService`. Edit a new module as follows:

```jolie
from CalculatorInterfaceModule import CalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

service CalculatorService {

}
```

This code permits to import the definition of the `CalculatorInterface` from module `CalculatorInterfaceModule` stored into file `CalculatorInterfaceModule.ol` and defines a service called `CalculatorService`.
This code permits to import the definition of the `CalculatorInterface` from module `CalculatorInterfaceModule` stored into file `CalculatorInterfaceModule.ol` and defines a service called `CalculatorService`. The dot prefix tells Jolie that it should find the module in the same directory.

### Defining the inputPort

Unfortunately, the code above will raise an error if executed, because the service definition does not contain any listening port nor any behaviour too. Let's start by defining a listening endpoint for this service:

```jolie
rom CalculatorInterfaceModule import CalculatorInterface
rom .CalculatorInterfaceModule import CalculatorInterface

service CalculatorService {

Expand All @@ -110,7 +110,7 @@ Listening endpoints in Jolie are called `inputPort`. In this example we defined
Now, the service is ready to receive messages on the operation specified in interface `CalculatorInterface` but we did not tell it what to do once a message is received. It is time to finalize the service by specifying the behaviour:

```jolie
from CalculatorInterfaceModule import CalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

service CalculatorService {

Expand Down Expand Up @@ -205,7 +205,7 @@ In order to enable the service to continuously serve requests we need to specify
So, let's admire our first service in Jolie!

```jolie
from CalculatorInterfaceModule import CalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

service CalculatorService {

Expand Down
72 changes: 72 additions & 0 deletions src/tutorials/standard-library/scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Using cron scheduler

In this section we provide an example on how to use the scheduler library for setting cron jobs in Jolie.
Before showing the example, leu us show the target architecture.

![scheduler.png](scheduler.png)

The test service embeds `Scheduler` imported from package `scheduler`.
THe Scheduler Service can be programmed by setting the OneWay operation wbere receiving the alarms when they are triggered by the jobs. The jobs can be added and deleted easily, by using the API offered by the Scheduler Service.

In the following example we report the code. Juts run it with the following command:
```
jolie test.ol
```

A job which runs every minute will trigegr the alarm, and a message with the job name and the group name will be printed out.

```
from scheduler import Scheduler // imported the Scheduler
from console import Console

type SchedulerCallBackRequest: void {
.jobName: string
.groupName: string
}

interface SchedulerCallBackInterface {
OneWay:
schedulerCallback( SchedulerCallBackRequest ) // definition of the call-back operation
}

service Test {

execution: concurrent

embed Scheduler as Scheduler // embedding the scheduler service
embed Console as Console


// internal input port for receiving alarms from Scheduler
inputPort MySelf {
location: "local"
interfaces: SchedulerCallBackInterface
}

init {
// setting the name of the callback operation
setCallbackOperation@Scheduler( { operationName = "schedulerCallback" })
// setting cronjob
setCronJob@Scheduler( {
jobName = "myjobname"
groupName = "myGroupName"
cronSpecs << {
second = "0"
minute = "0/1"
hour = "*"
dayOfMonth = "1/1"
month = "*"
dayOfWeek = "?"
year = "*"
}
})()
enableTimestamp@Console( true )()
}

main {
[ schedulerCallback( request ) ] {
println@Console( request.jobName + "/" + request.groupName )()
}
}
}
```
1 change: 1 addition & 0 deletions src/tutorials/standard-library/scheduler/scheduler
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2024-10-31T13:35:15.973Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/18.1.3 Chrome/100.0.4896.143 Electron/18.2.3 Safari/537.36" etag="_ivqBq2kSQs2hx-eRuxy" version="18.1.3" type="device"><diagram id="XjyVSPPcmfD7yR4UMwtE" name="Pagina-1">5VhRc5s4EP41fn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3vcRByXYnihlzE6gpqJyxdRrt+U+7G1JDWBqbZJl8Fby3F3vEMrmCY/6CG1YNXFYFSJHqvU+zaz2lxY3EOkGIqETqM5DLxAQg+5bbuaIP7rgKHRkQLz/XJfrb2V01P8sd2c10Kj31+jrgPAZkjvhhfhMyVn5oLfJx0rVe4NULyi56YmKm/xMxY2Rq5T/KzkoMQ77TtTc60SEbvORtnZvPnXjd98B</diagram></mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/tutorials/using-dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ The service offers three operations: `factorial`, `average` and `percentage` who
In the following we report the actual definition of the `AdvancedCalculatorService`:

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

service AdvancedCalculatorService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ The complete example follows and it may be consulted at this [link]
(<https://github.com/jolie/examples/tree/master/v1.10.x/tutorials/more_inputports_and_protocols/https>)

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

interface ChuckNorrisIface {
RequestResponse: random( undefined )( undefined )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ The complete example follows and it may be consulted at this [link]
(<https://github.com/jolie/examples/tree/master/v1.10.x/tutorials/more_inputports_and_protocols/soaps>)

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

interface ChuckNorrisIface {
RequestResponse: random( undefined )( undefined )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The complete example follows and it may be consulted at this [link]
(<https://github.com/jolie/examples/tree/master/v1.10.x/tutorials/more_inputports_and_protocols/sodep>)

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

interface ChuckNorrisIface {
RequestResponse: random( undefined )( undefined )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ The complete example follows and it may be consulted at this [link]
(<https://github.com/jolie/examples/tree/master/v1.10.x/tutorials/more_inputports_and_protocols/sodeps>)

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

interface ChuckNorrisIface {
RequestResponse: random( undefined )( undefined )
Expand Down
4 changes: 2 additions & 2 deletions src/tutorials/using-more-than-one-dependency/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ It is worth noting that all the response messages, now contain a new field calle
In the following we report the definition of the `AdvancedCalculatorService`.

```jolie
from AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from CalculatorInterfaceModule import CalculatorInterface
from .AdvancedCalculatorServiceInterfaceModule import AdvancedCalculatorInterface
from .CalculatorInterfaceModule import CalculatorInterface

interface ChuckNorrisIface {
RequestResponse: random( undefined )( undefined )
Expand Down