Skip to content

Commit 7ff5705

Browse files
committed
Many fixes, IRIS support
1 parent 06d2b19 commit 7ff5705

20 files changed

Lines changed: 9904 additions & 319 deletions

docker-compose.iris.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "3"
2+
3+
services:
4+
server:
5+
build:
6+
context: server
7+
dockerfile: Dockerfile-iris
8+
args:
9+
IRIS_KEY: ${IRIS_KEY}
10+
IRIS_VERSION: ${IRIS_VERSION}
11+
ports:
12+
- "${IRIS_WEBPORT-52773}:52773"
13+
- "${IRIS_PORT-51773}:51773"
14+
volumes:
15+
- ~/iris.key:/usr/irissys/mgr/iris.key
16+
- ./server/src:/opt/blocks/src
17+
web:
18+
build:
19+
context: web
20+
links:
21+
- server
22+
environment:
23+
- DB_HOST=server
24+
- DB_PORT=${IRIS_WEBPORT-52773}
25+
- WEB_PORT=${WEB_PORT-80}
26+
ports:
27+
- "${WEB_PORT-80}:${WEB_PORT-80}"
28+
volumes:
29+
- node_modules:/opt/app/node_modules
30+
- web_build:/opt/app/build
31+
- ./web:/opt/app
32+
volumes:
33+
node_modules: null
34+
web_build: null

docker-compose.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
version: "3"
22

33
services:
4-
cache:
4+
server:
55
build:
6-
context: cache
6+
context: server
77
args:
8-
CACHE_KEY: ${CACHE_KEY}
98
CACHE_VERSION: ${CACHE_VERSION}
109
ports:
1110
- "${CACHE_WEBPORT-57772}:57772"
1211
- "${CACHE_PORT-1972}:1972"
1312
volumes:
14-
- ./cache/src:/opt/blocks/src
15-
- blocks_data:/opt/blocks
13+
- ~/cache.key:/usr/cachesys/mgr/cache.key
14+
- ./server/src:/opt/blocks/src
1615
web:
1716
build:
1817
context: web
1918
links:
20-
- cache:db
19+
- server
2120
environment:
22-
- DB_HOST=db
21+
- DB_HOST=server
2322
- DB_PORT=${CACHE_WEBPORT-57772}
2423
- WEB_PORT=${WEB_PORT-80}
2524
ports:
@@ -31,4 +30,3 @@ services:
3130
volumes:
3231
node_modules: null
3332
web_build: null
34-
blocks_data: null

cache/Dockerfile renamed to server/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ WORKDIR /opt/blocks
55

66
COPY ./src/ ./src
77

8-
ARG CACHE_KEY=
9-
RUN echo -e "${CACHE_KEY}" > /opt/cache/mgr/cache.key
10-
118
RUN ccontrol start $ISC_PACKAGE_INSTANCENAME quietly \
129
&& echo -e "" \
1310
"do ##class(%SYSTEM.OBJ).Load(\"/opt/blocks/src/DevInstaller.cls\",\"cdk\")\n" \
@@ -18,4 +15,4 @@ RUN ccontrol start $ISC_PACKAGE_INSTANCENAME quietly \
1815
# Stop Caché instance
1916
&& ccontrol stop $ISC_PACKAGE_INSTANCENAME quietly
2017

21-
VOLUME [ "/opt/blocks" ]
18+
VOLUME [ "/opt/blocks/db" ]

server/Dockerfile-iris

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG IRIS_VERSION=2018.1
2+
FROM daimor/intersystems-iris:${IRIS_VERSION}
3+
4+
WORKDIR /opt/blocks
5+
6+
COPY ./src/ ./src
7+
8+
RUN iris start $ISC_PACKAGE_INSTANCENAME quietly \
9+
&& /bin/echo -e "do ##class(%SYSTEM.OBJ).Load(\"/opt/blocks/src/DevInstaller.cls\",\"cdk\")\n" \
10+
"set sc=##class(Blocks.DevInstaller).setupWithVars(\"/opt/blocks/\")\n" \
11+
"do:'sc \$zu(4,\$j,1)\n" \
12+
"Halt\n" \
13+
| iris session ${ISC_PACKAGE_INSTANCENAME} \
14+
&& iris stop $ISC_PACKAGE_INSTANCENAME quietly
15+
16+
VOLUME [ "/opt/blocks/db" ]
17+
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ XData UrlMap
1010
<Route Url="(?:/rest)?/ping" Method="GET" Call="Ping"/>
1111
<Route Url="(?:/rest)?/block/:block" Method="GET" Call="BlockInfo"/>
1212
<Route Url="(?:/rest)?/block/:block" Method="POST" Call="BlockInfo"/>
13-
<Route Url="/websocket" Method="GET" Call="WebSocket"/>
1413
<Route Url="/((?!rest/).*)" Method="GET" Call="GetStatic"/>
1514
</Routes>
1615
}
1716

18-
ClassMethod WebSocket() As %Status
17+
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
1918
{
20-
quit ##class(Blocks.WebSocket).Page()
19+
if pUrl = "/websocket" {
20+
set pContinue = 0
21+
set %response.ServerSideRedirect = "/csp/blocks/Blocks.WebSocket.cls"
22+
}
23+
Quit $$$OK
2124
}
2225

2326
ClassMethod outputJSON(data)
Lines changed: 29 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ Method OnPreServer() As %Status
2525

2626
Method Server() As %Status
2727
{
28-
Set timeout=.5
28+
Set timeout=.1
2929
set quit=0
30-
set dataGN="",event=""
3130
#dim exception As %Exception.AbstractException
3231
Set len=32656
3332
while 'quit {
3433
try {
35-
Set data=..Read(.len, .status, $select($isobject(event):0.1,1:timeout))
34+
Set data=..Read(.len, .status, timeout)
3635
If $$$ISERR(status),$$$GETERRORCODE(status) = $$$CSPWebSocketClosed {
3736
set quit=1
3837
quit
@@ -65,7 +64,7 @@ Method SendBlocksData() As %Status
6564
set child = ..ChildPID
6665
set resName = ..ResourceName
6766

68-
set responseData = ##class(%ListOfDataTypes).%New()
67+
set responseData = ##class(%DynamicArray).%New()
6968
kill blocksData
7069
set countData=0
7170
set atEnd=0
@@ -79,30 +78,29 @@ Method SendBlocksData() As %Status
7978
set $listbuild(parent,block,global,fill)=data
8079
if $p(..Event,"_",2)="tree" {
8180
if '$data(blocksData(parent)) {
82-
set blocksData(parent)=##class(%ZEN.proxyObject).%New()
81+
set blocksData(parent)=##class(%DynamicObject).%New()
8382
set blocksData(parent).block = parent
84-
set blocksData(parent).child = ##class(%ListOfDataTypes).%New()
85-
do responseData.Insert(blocksData(parent))
83+
set blocksData(parent).child = ##class(%DynamicArray).%New()
84+
do responseData.%Push(blocksData(parent))
8685
}
87-
do blocksData(parent).child.Insert(block)
86+
do blocksData(parent).child.%Push(block)
8887
} else {
8988
if '$data(blocksData(global)) {
90-
set blocksData(global)=##class(%ZEN.proxyObject).%New()
89+
set blocksData(global)=##class(%DynamicObject).%New()
9190
set blocksData(global).global = global
92-
set blocksData(global).blocks = ##class(%ListOfDataTypes).%New()
93-
do responseData.Insert(blocksData(global))
91+
set blocksData(global).blocks = ##class(%DynamicArray).%New()
92+
do responseData.%Push(blocksData(global))
9493
}
95-
set blockInfo = ##class(%ListOfDataTypes).%New()
96-
do blockInfo.Insert(block)
97-
do blockInfo.Insert(fill)
98-
do blocksData(global).blocks.Insert(blockInfo)
94+
set blockInfo = ##class(%DynamicArray).%New()
95+
do blockInfo.%Push(block)
96+
do blockInfo.%Push(fill)
97+
do blocksData(global).blocks.%Push(blockInfo)
9998
kill blockInfo
10099
}
101100
quit:$i(countData)>=1000
102101
}
103-
104102
if responseData.Size > 0 {
105-
do ..Write(..Event, responseData)
103+
do ..Write(..Event, responseData)
106104
}
107105
if atEnd {
108106
set ..Event = ""
@@ -111,13 +109,14 @@ Method SendBlocksData() As %Status
111109
quit $$$OK
112110
}
113111

114-
Method Action(obj As %ZEN.proxyObject) As %Status
112+
Method Action(obj As %DynamicObject) As %Status
115113
{
116114
set st = $$$OK
117115
#dim exception As %Exception.AbstractException
118116
try {
117+
quit:obj=""
119118
set action = obj.event
120-
set data = ##class(%ListOfDataTypes).%New()
119+
set data = ##class(%DynamicArray).%New()
121120
if action="ping" {
122121
set sc=..Write(action, "pong")
123122
} elseif $p(action,"_")="blocks" {
@@ -228,7 +227,7 @@ ClassMethod ReadBlocks(aAsTree As %Boolean = 0, aBlockId As %Integer = 3, aParen
228227
add(parentBlock,blockId,global,offset)
229228
set data=$listbuild(parentBlock,blockId)
230229
if 'aAsTree set data=data_$listbuild(global,$j(offset/blockSize*100,0,0))
231-
do $system.Event.Signal(ResourceName, data)
230+
do $system.Event.Signal(ResourceName, data)
232231
}
233232

234233
/// Reads up to len characters from the client.
@@ -238,8 +237,13 @@ Method Read(ByRef len As %Integer = 32656, ByRef sc As %Status, timeout As %Inte
238237
{
239238
Set json = ##super(len, .sc, timeout)
240239
Do:$$$ISERR(sc) ..EndServer()
241-
Set st = ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(json,,.obj,1)
242-
Do:$$$ISERR(st) ..EndServer()
240+
quit:json="" ""
241+
try {
242+
set obj = ##class(%DynamicObject).%FromJSON(json)
243+
} catch ex {
244+
set sc = ex.AsStatus()
245+
set obj = ""
246+
}
243247
Quit obj
244248
}
245249

@@ -248,49 +252,12 @@ Method Write(eventName As %String = "", data As %String) As %Status
248252
if '$d(data) {
249253
quit ##super(eventName)
250254
}
251-
set response = ##class(%ZEN.proxyObject).%New()
255+
set response = ##class(%DynamicObject).%New()
252256
set response.event = eventName
253257
set response.data = data
254258

255-
Quit ##super(..OutputToStr(response,"%ToJSON"))
256-
}
257-
258-
ClassMethod OutputToStr(obj, method, args...) As %String [ ProcedureBlock = 0 ]
259-
{
260-
Set str=""
261-
//Redirect IO to the current routine - makes use of the labels defined below
262-
Use $io::("^"_$ZNAME)
263-
264-
//Enable redirection
265-
Do ##class(%Device).ReDirectIO(1)
266-
267-
if $isobject(obj) {
268-
Do $Method(obj,method,args...)
269-
} elseif $$$comClassDefined(obj) {
270-
Do $ClassMethod(obj,method,args...)
271-
}
272-
273-
//Disable redirection
274-
Do ##class(%Device).ReDirectIO(0)
275-
Quit str
276-
//Labels that allow for IO redirection
277-
//Read Character - we Don't care about reading
278-
rchr(c) quit
279-
//Read a string - we Don't care about reading
280-
rstr(sz,to) quit
281-
//Write a character - call the output label
282-
wchr(s) Do output($char(s)) quit
283-
//Write a form feed - call the output label
284-
wff() Do output($char(12)) quit
285-
//Write a newline - call the output label
286-
wnl() Do output($char(13,10)) quit
287-
//Write a string - call the output label
288-
wstr(s) Do output(s) quit
289-
//Write a tab - call the output label
290-
wtab(s) Do output($char(9)) quit
291-
//Output label - this is where you would handle what you actually want to Do.
292-
// in our case, we want to Write to str
293-
output(s) Set str=str_s quit
259+
set json = response.%ToJSON()
260+
quit ##super(json)
294261
}
295262

296263
}

0 commit comments

Comments
 (0)