Rechercher

Article
· Fév 10, 2021 3m de lecture

using ZPM for Node.js

Inspired by  @Evgeny Shvarov  and his recent article
Deploying InterSystems IRIS Embedded Python Solutions with ZPM Package Manager
I propagated the idea forward to do the same also for modules in Node.js.
The case is based on my example of IRIS Native API for Node.js

UPDATE

  • All additional required Node.js components can now be installed at runtime.   
  • Only intersystems-iris-native module is pre-installed during Docker build.
  • When Node.js is launched its Process id is displayed for debugging purpose.
  • Some optical cosmetics and runtime improvements.

This step and adjusting access rights are covered in Dockerfile.
But all your .js modules are handled by ZPM.

The logic of the example hasn't changed.

  • the Nodes.js service is started
  • the selected address of the echo server is passed to it > E
  • you compose the text to be transmitted > N
  • you send it and see how the replies are dropping in > S
  • stop service and exit > X

Different from the original example, the service is now running in background.
So its output is invisible but writes a log file that can be view by the action > L

Prerequisites

Make sure you have git and Docker desktop installed.

Installation

Clone/git pull this repo into any local directory

$ git clone https://github.com/rcemper/Using-ZPM-for-Node.js 

Open the terminal in this directory and run:

$ docker-compose build

this may take some time to complete

Run the IRIS container with this project:

$ docker-compose up -d

How to Test it

Using IRIS terminal:

$ docker-compose exec iris iris session iris "##class(rccjs.WSockNodeJs).Run()"

*** Welcome to WebSocket by Node.js Native API Demo ***

********* Node.js process id = 1650 *********

Known Hosts (*=Exit) [1]:
1 wss://ws.postman-echo.com/raw
2 --- server 2 ----
3 --- server 3 ----
select (1): 1 ==> wss://ws.postman-echo.com/raw

 

Enter text to get echoed from WebSocketClient Service
Terminate with * at first position
or get generated text by %
or append new text with @

1 hello this is connected over
2 IRIS Native API for Node.js
3 -----------------
4 *

Select action for WebClient Service
New EchoServer (E), New Text(N), Send+Listen(S)
Show Log (L), Exit+Stop WsClient(X) [S] :s
%%%%%%%%%%%%%%%%%%%%%%%%%%

******* 3 Replies *******
1 hello this is connecte over 
2 IRIS Native API for Node.js 
3 -----------------

Select action for WebClient Service
New EchoServer (E), New Text(N), Send+Listen(S)
Show Log (L), Exit+Stop WsClient(X) [S] :L
%%%%%%%%%%%%%%%%%%%%%%%%%%

platform = linux: ubuntu

    *****************************
    *** no IRIS host defined ****
    Connect to IRIS on: localhost

Successfully connected to InterSystems IRIS.
*** wait 3sec for request ***
******* Startup done ********

    *** wait 3sec for request ***
    *** wait 3sec for request ***
    *** wait 3sec for request ***
    *** wait 3sec for request ***
    echoserver:  wss://ws.postman-echo.com/raw
    ** Lines to process: 3 **
    ********* next turn *********
    * WebSocket Client connected *
    ****** Client is ready ******

Line: 1 text> 'hello this is connecte over '
Received: 1 > 'hello this is connecte over '
Line: 2 text> 'IRIS Native API for Node.js '
Received: 2 > 'IRIS Native API for Node.js '
Line: 3 text> '----------------- '
Received: 3 > '----------------- '

    ******* lines sent: 3 ******
    *** replies received: 3 ****

    *** wait 3sec for request ***
    *** wait 3sec for request ***

Select action for WebClient Service
New EchoServer (E), New Text(N), Send+Listen(S)
Show Log (L), Exit+Stop WsClient(X) [S] :x
%%%%%%%%%%%%%%%%%%%%%%%%%%

GitHub

2 Comments
Discussion (2)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Fév 8, 2021 2m de lecture

Websocket Client Embedded Python

This is a demo to make use of a simple WebSocket Client with Embedded Python in IRIS.

How to Test it

  • Run an Iris Session in Docker
  • Select your WebSocket Echo Server
  • Enter the text you want to send or generate it
  • Send it and see the result
$ docker-compose exec iris iris session iris "##class(rccpy.WSockPy).Run()"

*** Welcome to WebSocket Embedded Python Demo ***

Collecting websocket-client
Using cached https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl
Collecting six (from websocket-client)
Using cached https://files.pythonhosted.org/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl
Installing collected packages: six, websocket-client
Successfully installed six-1.15.0 websocket-client-0.57.0

%%%%%%

Known Hosts (*=Exit) [1]:
1 ws://echo.websocket.org/
2 --- server 2 ----
3 --- server 3 ----
select (1): 1 ==> ws://echo.websocket.org/
Python Connection Object:#
Enter text to get echoed from WebSocketClient Service
Terminate with * at first position
or get generated text by %
or append new text with @

1 hi this is python
2 from IRIS
3 *

Select action for WebSocket Service
Send+Listen(S),New Text(N),Exit(X) [S]S
%%%%%%%%%%%%%%%%%%%%%%%%%%

******* Submit 2 Lines *******
1 send> hi this is python
recv< hi this is python
2 send> from IRIS
recv< from IRIS

Select action for WebSocket Service
Send+Listen(S),New Text(N),Exit(X) [S]n
%%%%%%%%%%%%%%%%%%%%%%%%%%
Enter text to get echoed from WebSocketClient Service
Terminate with * at first position
or get generated text by %
or append new text with @

1 with some more text
2 %
2 * Lorem ipsum dolor sit amet, consectetuer adipiscing
3 * elit, sed diam nonummy nibh euismod tincidunt ut
. . . .
32 * un simplificat Angles, quam
33 * un skeptic Cambridge amico dit me que Occidental es.
34 *

Select action for WebSocket Service
Send+Listen(S),New Text(N),Exit(X) [S]s
%%%%%%%%%%%%%%%%%%%%%%%%%%

******* Submit 33 Lines *******
1 send> with some more text
recv< with some more text
2 send> Lorem ipsum dolor sit amet, consectetuer adipiscing
recv< Lorem ipsum dolor sit amet, consectetuer adipiscing
3 send> elit, sed diam nonummy nibh euismod tincidunt ut
recv< elit, sed diam nonummy nibh euismod tincidunt ut
. . . .
32 send> un simplificat Angles, quam
recv< un simplificat Angles, quam
33 send> un skeptic Cambridge amico dit me que Occidental es.
recv< un skeptic Cambridge amico dit me que Occidental es.

Select action for WebSocket Service
Send+Listen(S),New Text(N),Exit(X) [S]x
%%%%%%%%%%%%%%%%%%%%%%%%%%

$

Hints

%SYS.Python.html is a preliminary class docu to see available functions

run time: If the standard Python module is not yet installed this is the first action and happens only once.

GitHub

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Question
· Fév 3, 2021

Extracting last value in a repeating field

Hi,

I have a PV1 repeating field that can contain multiple or a single value. I'd like to always pull the last value in the field but am not sure how to configure this in my DTL.

The repeating field is in PV1:50().1

Could somebody shed some light on this?

 

Examples:

|15081942~15081951~15108961~15280550|

|15081947|

|15081939~15081940|

 

Thanks

5 Comments
Discussion (5)2
Connectez-vous ou inscrivez-vous pour continuer
Article
· Fév 2, 2021 9m de lecture

Caché データベースブロックの内部構造、パート 2

この記事は Caché データベースの内部構造を説明したこちらの記事の続編です。 そちらの記事では、様々なブロックタイプ、それぞれのつながりやグローバルとの関係について説明しました。 純粋に理論を述べた記事でした。 ブロックツリーを視覚化するのに役立つプロジェクトを作成しましたので、この記事ではその仕組みを詳しく説明します。

Discussion (0)2
Connectez-vous ou inscrivez-vous pour continuer
Question
· Fév 1, 2021

IKO (Iris Kubernetes Operator) Service not redirecting dynamically to the correct Pod

In the context of IKO (Iris Kubernetes Operator) the question of Service not redirecting dynamically to the correct Pod is still pending.
In production this can be dangerous since an overload (or any other simpler problem) can cause you to change the main Pod and leave the application inoperable until we intervene.

Intersystems support warned that this is still an issue of IKO, but there are some possibilities that I am studying.

To explore an idea I had, I would like the help of this Forum to answer the following question:

Is there a way, via the non-iterative command line, to detect whether the current Iris instance is a primary member of Mirror or a backup?

I imagine it would be enough if I could detect whether a particular database is write-protected or not ...

I have access to the Linux terminal of the host machine with the "iris", "irissession" and other applications present or that can be installed.

3 Comments
Discussion (3)0
Connectez-vous ou inscrivez-vous pour continuer