From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/jaegertracing/thrift/tutorial/haxe/Makefile.am | 97 ++++++ .../thrift/tutorial/haxe/Tutorial.hxproj | 67 ++++ src/jaegertracing/thrift/tutorial/haxe/cpp.hxml | 41 +++ src/jaegertracing/thrift/tutorial/haxe/csharp.hxml | 38 +++ src/jaegertracing/thrift/tutorial/haxe/flash.hxml | 41 +++ src/jaegertracing/thrift/tutorial/haxe/java.hxml | 38 +++ .../thrift/tutorial/haxe/javascript.hxml | 44 +++ .../thrift/tutorial/haxe/make_all.bat | 68 ++++ src/jaegertracing/thrift/tutorial/haxe/make_all.sh | 41 +++ src/jaegertracing/thrift/tutorial/haxe/neko.hxml | 38 +++ .../thrift/tutorial/haxe/php-web-server.hxml | 43 +++ src/jaegertracing/thrift/tutorial/haxe/php.hxml | 39 +++ .../thrift/tutorial/haxe/project.hide | 105 ++++++ src/jaegertracing/thrift/tutorial/haxe/python.hxml | 38 +++ src/jaegertracing/thrift/tutorial/haxe/router.php | 31 ++ .../thrift/tutorial/haxe/src/CalculatorHandler.hx | 101 ++++++ src/jaegertracing/thrift/tutorial/haxe/src/Main.hx | 375 +++++++++++++++++++++ 17 files changed, 1245 insertions(+) create mode 100644 src/jaegertracing/thrift/tutorial/haxe/Makefile.am create mode 100644 src/jaegertracing/thrift/tutorial/haxe/Tutorial.hxproj create mode 100644 src/jaegertracing/thrift/tutorial/haxe/cpp.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/csharp.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/flash.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/java.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/javascript.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/make_all.bat create mode 100644 src/jaegertracing/thrift/tutorial/haxe/make_all.sh create mode 100644 src/jaegertracing/thrift/tutorial/haxe/neko.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/php-web-server.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/php.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/project.hide create mode 100644 src/jaegertracing/thrift/tutorial/haxe/python.hxml create mode 100644 src/jaegertracing/thrift/tutorial/haxe/router.php create mode 100644 src/jaegertracing/thrift/tutorial/haxe/src/CalculatorHandler.hx create mode 100644 src/jaegertracing/thrift/tutorial/haxe/src/Main.hx (limited to 'src/jaegertracing/thrift/tutorial/haxe') diff --git a/src/jaegertracing/thrift/tutorial/haxe/Makefile.am b/src/jaegertracing/thrift/tutorial/haxe/Makefile.am new file mode 100644 index 000000000..e6f271346 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/Makefile.am @@ -0,0 +1,97 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +BIN_CPP = bin/Main-debug +BIN_PHP = bin/php/Main-debug.php +BIN_PHP_WEB = bin/php-web-server/Main-debug.php + +gen-haxe/tutorial/calculator.hx gen-haxe/shared/shared_service.hx: $(top_srcdir)/tutorial/tutorial.thrift + $(THRIFT) --gen haxe -r $< + +all-local: $(BIN_CPP) $(BIN_PHP) $(BIN_PHP_WEB) + +check: gen-haxe/tutorial/calculator.hx + +$(BIN_CPP): \ + src/*.hx \ + ../../lib/haxe/src/org/apache/thrift/**/*.hx \ + gen-haxe/tutorial/calculator.hx + $(HAXE) --cwd . cpp.hxml + +$(BIN_PHP): \ + src/*.hx \ + ../../lib/haxe/src/org/apache/thrift/**/*.hx \ + gen-haxe/tutorial/calculator.hx + $(HAXE) --cwd . php.hxml + +$(BIN_PHP_WEB): \ + src/*.hx \ + ../../lib/haxe/src/org/apache/thrift/**/*.hx \ + gen-haxe/tutorial/calculator.hx + $(HAXE) --cwd . php-web-server.hxml + +tutorialserver: all + $(BIN_CPP) server + +tutorialserver_php: all + php -f $(BIN_PHP) server + +tutorialclient: all + $(BIN_CPP) + +tutorialclient_php: all + php -f $(BIN_PHP) + +tutorialsecureserver: all + $(BIN_CPP) server secure + +tutorialsecureserver_php: all + php -f $(BIN_PHP) server secure + +tutorialsecureclient: all + $(BIN_CPP) secure + +tutorialsecureclient_php: all + php -f $(BIN_PHP) secure + +tutorialserver_php_http: all + php -S 127.0.0.1:9090 router.php + +tutorialclient_http: all + $(BIN_CPP) client http + +clean-local: + $(RM) -r gen-haxe bin + +EXTRA_DIST = \ + src \ + cpp.hxml \ + csharp.hxml \ + flash.hxml \ + java.hxml \ + javascript.hxml \ + php-web-server.hxml \ + neko.hxml \ + php.hxml \ + python.hxml \ + router.php \ + project.hide \ + Tutorial.hxproj \ + make_all.bat \ + make_all.sh diff --git a/src/jaegertracing/thrift/tutorial/haxe/Tutorial.hxproj b/src/jaegertracing/thrift/tutorial/haxe/Tutorial.hxproj new file mode 100644 index 000000000..796f648a5 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/Tutorial.hxproj @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + thrift -r -gen haxe ../tutorial.thrift + + + + + + + + \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/cpp.hxml b/src/jaegertracing/thrift/tutorial/haxe/cpp.hxml new file mode 100644 index 000000000..6adb52d7e --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/cpp.hxml @@ -0,0 +1,41 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#CPP target +-cpp bin + +#To produce 64 bit binaries the file should define the HXCPP_M64 compile variable: +#-D HXCPP_M64 + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/csharp.hxml b/src/jaegertracing/thrift/tutorial/haxe/csharp.hxml new file mode 100644 index 000000000..295c017e7 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/csharp.hxml @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#CSHARP target +-cs bin/Tutorial.exe + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/flash.hxml b/src/jaegertracing/thrift/tutorial/haxe/flash.hxml new file mode 100644 index 000000000..a1f0568ad --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/flash.hxml @@ -0,0 +1,41 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#Flash target +-swf bin/Tutorial.swf + +#Add debug information +-debug + +# we need some goodies from sys.net +# --macro allowPackage("sys") + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/java.hxml b/src/jaegertracing/thrift/tutorial/haxe/java.hxml new file mode 100644 index 000000000..c615565a9 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/java.hxml @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#Java target +-java bin/Tutorial.jar + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/javascript.hxml b/src/jaegertracing/thrift/tutorial/haxe/javascript.hxml new file mode 100644 index 000000000..b2b3876cf --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/javascript.hxml @@ -0,0 +1,44 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#JavaScript target +-js bin/Tutorial.js + +#You can use -D source-map-content (requires Haxe 3.1+) to have the .hx +#files directly embedded into the map file, this way you only have to +#upload it, and it will be always in sync with the compiled .js even if +#you modify your .hx files. +-D source-map-content + +#Generate source map and add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/make_all.bat b/src/jaegertracing/thrift/tutorial/haxe/make_all.bat new file mode 100644 index 000000000..656dd1530 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/make_all.bat @@ -0,0 +1,68 @@ +@echo off +rem /* +rem * Licensed to the Apache Software Foundation (ASF) under one +rem * or more contributor license agreements. See the NOTICE file +rem * distributed with this work for additional information +rem * regarding copyright ownership. The ASF licenses this file +rem * to you under the Apache License, Version 2.0 (the +rem * "License"); you may not use this file except in compliance +rem * with the License. You may obtain a copy of the License at +rem * +rem * http://www.apache.org/licenses/LICENSE-2.0 +rem * +rem * Unless required by applicable law or agreed to in writing, +rem * software distributed under the License is distributed on an +rem * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +rem * KIND, either express or implied. See the License for the +rem * specific language governing permissions and limitations +rem * under the License. +rem */ + +setlocal +if "%HOMEDRIVE%"=="" goto MISSINGVARS +if "%HOMEPATH%"=="" goto MISSINGVARS +if "%HAXEPATH%"=="" goto NOTINSTALLED + +set path=%HAXEPATH%;%HAXEPATH%\..\neko;%path% + +rem # invoke Thrift comnpiler +thrift -r -gen haxe ..\tutorial.thrift +if errorlevel 1 goto STOP + +rem # invoke Haxe compiler for all targets +for %%a in (*.hxml) do ( + rem * filter Python, as it is not supported by Haxe 3.1.3 (but will be in 3.1.4) + if not "%%a"=="python.hxml" ( + echo -------------------------- + echo Building %%a ... + echo -------------------------- + haxe --cwd . %%a + ) +) + + +echo. +echo done. +pause +goto eof + +:NOTINSTALLED +echo FATAL: Either Haxe is not installed, or the HAXEPATH variable is not set. +pause +goto eof + +:MISSINGVARS +echo FATAL: Unable to locate home folder. +echo. +echo Both HOMEDRIVE and HOMEPATH need to be set to point to your Home folder. +echo The current values are: +echo HOMEDRIVE=%HOMEDRIVE% +echo HOMEPATH=%HOMEPATH% +pause +goto eof + +:STOP +pause +goto eof + +:eof diff --git a/src/jaegertracing/thrift/tutorial/haxe/make_all.sh b/src/jaegertracing/thrift/tutorial/haxe/make_all.sh new file mode 100644 index 000000000..2ee650dce --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/make_all.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# invoke Thrift comnpiler +thrift -r -gen haxe ../tutorial.thrift + +# output folder +if [ ! -d bin ]; then + mkdir bin +fi + +# invoke Haxe compoiler +for target in *.hxml; do + echo -------------------------- + echo Building ${target} ... + echo -------------------------- + if [ ! -d bin/${target} ]; then + mkdir bin/${target} + fi + haxe --cwd . ${target} +done + + +#eof diff --git a/src/jaegertracing/thrift/tutorial/haxe/neko.hxml b/src/jaegertracing/thrift/tutorial/haxe/neko.hxml new file mode 100644 index 000000000..6161f6977 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/neko.hxml @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#neko target +-neko bin/Tutorial.n + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/php-web-server.hxml b/src/jaegertracing/thrift/tutorial/haxe/php-web-server.hxml new file mode 100644 index 000000000..395a8521e --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/php-web-server.hxml @@ -0,0 +1,43 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#PHP target +-php bin/php-web-server/ +--php-front Main-debug.php + +#defines +-D phpwebserver + + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full diff --git a/src/jaegertracing/thrift/tutorial/haxe/php.hxml b/src/jaegertracing/thrift/tutorial/haxe/php.hxml new file mode 100644 index 000000000..c2f68878e --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/php.hxml @@ -0,0 +1,39 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#PHP target +-php bin/php/ +--php-front Main-debug.php + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full diff --git a/src/jaegertracing/thrift/tutorial/haxe/project.hide b/src/jaegertracing/thrift/tutorial/haxe/project.hide new file mode 100644 index 000000000..8d5d4ec56 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/project.hide @@ -0,0 +1,105 @@ +{ + "type" : 0 + ,"target" : 4 + ,"name" : "Apache Thrift Tutorial" + ,"main" : null + ,"projectPackage" : "" + ,"company" : "Apache Software Foundation (ASF)" + ,"license" : "Apache License, Version 2.0" + ,"url" : "http://www.apache.org/licenses/LICENSE-2.0" + ,"targetData" : [ + { + "pathToHxml" : "flash.hxml" + ,"runActionType" : 1 + ,"runActionText" : "bin/Tutorial.swf" + } + ,{ + "pathToHxml" : "javascript.hxml" + ,"runActionType" : 1 + ,"runActionText" : "bin\\index.html" + } + ,{ + "pathToHxml" : "neko.hxml" + ,"runActionType" : 2 + ,"runActionText" : "neko bin/Tutorial.n" + } + ,{ + "pathToHxml" : "php.hxml" + } + ,{ + "pathToHxml" : "cpp.hxml" + ,"runActionType" : 2 + ,"runActionText" : "bin/Main-debug.exe" + } + ,{ + "pathToHxml" : "java.hxml" + } + ,{ + "pathToHxml" : "csharp.hxml" + ,"runActionType" : 2 + ,"runActionText" : "bin\\Tutorial.exe\\bin\\Main-Debug.exe" + } + ,{ + "pathToHxml" : "python.hxml" + ,"runActionType" : 2 + ,"runActionText" : "python bin/Tutorial.py" + } + ] + ,"files" : [ + { + "path" : "src\\org\\apache\\thrift\\server\\TServer.hx" + ,"useTabs" : true + ,"indentSize" : 4 + ,"foldedRegions" : [ + + ] + ,"activeLine" : 76 + } + ,{ + "path" : "src\\org\\apache\\thrift\\server\\TSimpleServer.hx" + ,"useTabs" : true + ,"indentSize" : 4 + ,"foldedRegions" : [ + + ] + ,"activeLine" : 100 + } + ,{ + "path" : "src\\shared\\SharedServiceProcessor.hx" + ,"useTabs" : true + ,"indentSize" : 4 + ,"foldedRegions" : [ + + ] + ,"activeLine" : 20 + } + ,{ + "path" : "src\\tutorial\\CalculatorProcessor.hx" + ,"useTabs" : true + ,"indentSize" : 4 + ,"foldedRegions" : [ + + ] + ,"activeLine" : 79 + } + ,{ + "path" : "src\\Main.hx" + ,"useTabs" : true + ,"indentSize" : 4 + ,"foldedRegions" : [ + + ] + ,"activeLine" : 0 + } + ] + ,"activeFile" : "src\\Main.hx" + ,"openFLTarget" : null + ,"openFLBuildMode" : "Debug" + ,"runActionType" : null + ,"runActionText" : null + ,"buildActionCommand" : null + ,"hiddenItems" : [ + + ] + ,"showHiddenItems" : false +} \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/python.hxml b/src/jaegertracing/thrift/tutorial/haxe/python.hxml new file mode 100644 index 000000000..f2c19fa93 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/python.hxml @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#integrate files to classpath +-cp src +-cp gen-haxe +-cp ../../lib/haxe/src + +#this class wil be used as entry point for your app. +-main Main + +#Python target +-python bin/Tutorial.py + +#Add debug information +-debug + +#dead code elimination : remove unused code +#"-dce no" : do not remove unused code +#"-dce std" : remove unused code in the std lib (default) +#"-dce full" : remove all unused code +-dce full \ No newline at end of file diff --git a/src/jaegertracing/thrift/tutorial/haxe/router.php b/src/jaegertracing/thrift/tutorial/haxe/router.php new file mode 100644 index 000000000..e34135cc9 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/router.php @@ -0,0 +1,31 @@ +(); + + public function new() { + } + + public function ping() : Void { + trace("ping()"); + } + + + public function add( num1 : haxe.Int32, num2 : haxe.Int32) : haxe.Int32 { + trace('add( $num1, $num2)'); + return num1 + num2; + } + + public function calculate( logid : haxe.Int32, work : Work) : haxe.Int32 { + trace('calculate( $logid, '+work.op+","+work.num1+","+work.num2+")"); + + var val : haxe.Int32 = 0; + switch (work.op) + { + case Operation.ADD: + val = work.num1 + work.num2; + + case Operation.SUBTRACT: + val = work.num1 - work.num2; + + case Operation.MULTIPLY: + val = work.num1 * work.num2; + + case Operation.DIVIDE: + if (work.num2 == 0) + { + var io = new InvalidOperation(); + io.whatOp = work.op; + io.why = "Cannot divide by 0"; + throw io; + } + val = Std.int( work.num1 / work.num2); + + default: + var io = new InvalidOperation(); + io.whatOp = work.op; + io.why = "Unknown operation"; + throw io; + } + + var entry = new SharedStruct(); + entry.key = logid; + entry.value = '$val'; + log.set(logid, entry); + + return val; + } + + public function getStruct( key : haxe.Int32) : SharedStruct { + trace('getStruct($key)'); + return log.get(key); + } + + // oneway method, no args + public function zip() : Void { + trace("zip()"); + } + +} diff --git a/src/jaegertracing/thrift/tutorial/haxe/src/Main.hx b/src/jaegertracing/thrift/tutorial/haxe/src/Main.hx new file mode 100644 index 000000000..6bebe7164 --- /dev/null +++ b/src/jaegertracing/thrift/tutorial/haxe/src/Main.hx @@ -0,0 +1,375 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package; + +import org.apache.thrift.*; +import org.apache.thrift.protocol.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.server.*; +import org.apache.thrift.meta_data.*; + +import tutorial.*; +import shared.*; + + +enum Prot { + binary; + json; +} + +enum Trns { + socket; + http; +} + +class Main { + + private static var server : Bool = false; + private static var framed : Bool = false; + private static var buffered : Bool = false; + private static var prot : Prot = binary; + private static var trns : Trns = socket; + + private static var targetHost : String = "localhost"; + private static var targetPort : Int = 9090; + + static function main() { + + #if ! (flash || js || phpwebserver) + try { + ParseArgs(); + } catch (e : String) { + trace(e); + trace(GetHelp()); + return; + } + + #elseif phpwebserver + //forcing server + server = true; + trns = http; + initPhpWebServer(); + //check method + if(php.Web.getMethod() != 'POST') { + Sys.println('http endpoint for thrift test server'); + return; + } + #end + + try { + if (server) + RunServer(); + else + RunClient(); + } catch (e : String) { + trace(e); + } + + trace("Completed."); + } + + #if phpwebserver + private static function initPhpWebServer() + { + //remap trace to error log + haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos) + { + // handle trace + var newValue : Dynamic; + if (infos != null && infos.customParams!=null) { + var extra:String = ""; + for( v in infos.customParams ) + extra += "," + v; + newValue = v + extra; + } + else { + newValue = v; + } + var msg = infos != null ? infos.fileName + ':' + infos.lineNumber + ': ' : ''; + Sys.stderr().writeString('${msg}${newValue}\n'); + } + } + #end + + + #if ! (flash || js) + + private static function GetHelp() : String { + return Sys.executablePath()+" modus trnsOption transport protocol\n" + +"Options:\n" + +" modus: client, server (default: client)\n" + +" trnsOption: framed, buffered (default: none)\n" + +" transport: socket, http (default: socket)\n" + +" protocol: binary, json (default: binary)\n" + +"\n" + +"All arguments are optional.\n"; + } + + + private static function ParseArgs() : Void { + var step = 0; + for (arg in Sys.args()) { + + // server|client + switch(step) { + case 0: + ++step; + if ( arg == "client") + server = false; + else if ( arg == "server") + server = true; + else + throw "First argument must be 'server' or 'client'"; + + case 1: + if ( arg == "framed") { + framed = true; + } else if ( arg == "buffered") { + buffered = true; + } else if ( arg == "socket") { + trns = socket; + ++step; + } else if ( arg == "http") { + trns = http; + ++step; + } else { + throw "Unknown transport "+arg; + } + + case 2: + if ( arg == "binary") { + prot = binary; + ++step; + } else if ( arg == "json") { + prot = json; + ++step; + } else { + throw "Unknown protocol "+arg; + } + + default: + throw "Unexpected argument "+arg; + } + + if ( framed && buffered) + { + trace("WN: framed supersedes buffered"); + } + + } + } + + #end + + private static function ClientSetup() : Calculator { + trace("Client configuration:"); + + // endpoint transport + var transport : TTransport; + switch(trns) + { + case socket: + trace('- socket transport $targetHost:$targetPort'); + transport = new TSocket( targetHost, targetPort); + case http: + var uri = 'http://${targetHost}:${targetPort}'; + trace('- HTTP transport $uri'); + transport = new THttpClient(uri); + default: + throw "Unhandled transport"; + } + + + // optinal layered transport + if ( framed) { + trace("- framed transport"); + transport = new TFramedTransport(transport); + } else if ( buffered) { + trace("- buffered transport"); + transport = new TBufferedTransport(transport); + } + + + // protocol + var protocol : TProtocol; + switch(prot) + { + case binary: + trace("- binary protocol"); + protocol = new TBinaryProtocol( transport); + case json: + trace("- JSON protocol"); + protocol = new TJSONProtocol( transport); + default: + throw "Unhandled protocol"; + } + + + // put everything together + transport.open(); + return new CalculatorImpl(protocol,protocol); + } + + + private static function RunClient() : Void { + var client = ClientSetup(); + + try { + client.ping(); + trace("ping() successful"); + } catch(error : TException) { + trace('ping() failed: $error'); + } catch(error : Dynamic) { + trace('ping() failed: $error'); + } + + try { + var sum = client.add( 1, 1); + trace('1+1=$sum'); + } catch(error : TException) { + trace('add() failed: $error'); + } catch(error : Dynamic) { + trace('add() failed: $error'); + } + + + var work = new tutorial.Work(); + work.op = tutorial.Operation.DIVIDE; + work.num1 = 1; + work.num2 = 0; + try { + var quotient = client.calculate( 1, work); + trace('Whoa we can divide by 0! Result = $quotient'); + } catch(error : TException) { + trace('calculate() failed: $error'); + } catch(error : Dynamic) { + trace('calculate() failed: $error'); + } + + work.op = tutorial.Operation.SUBTRACT; + work.num1 = 15; + work.num2 = 10; + try { + var diff = client.calculate( 1, work); + trace('15-10=$diff'); + } catch(error : TException) { + trace('calculate() failed: $error'); + } catch(error : Dynamic) { + trace('calculate() failed: $error'); + } + + + try { + var log : SharedStruct = client.getStruct( 1); + var logval = log.value; + trace('Check log: $logval'); + } catch(error : TException) { + trace('getStruct() failed: $error'); + } catch(error : Dynamic) { + trace('getStruct() failed: $error'); + } + } + + + private static function ServerSetup() : TServer { + trace("Server configuration:"); + + // endpoint transport + var transport : TServerTransport = null; + switch(trns) + { + case socket: + #if (flash || js) + throw 'current platform does not support socket servers'; + #else + trace('- socket transport port $targetPort'); + transport = new TServerSocket( targetPort); + #end + case http: + #if !phpwebserver + throw "HTTP server not implemented yet"; + //trace("- http transport"); + //transport = new THttpClient( targetHost); + #else + trace("- http transport"); + transport = new TWrappingServerTransport( + new TStreamTransport( + new TFileStream("php://input", Read), + new TFileStream("php://output", Append) + ) + ); + + #end + default: + throw "Unhandled transport"; + } + + // optional: layered transport + var transfactory : TTransportFactory = null; + if ( framed) { + trace("- framed transport"); + transfactory = new TFramedTransportFactory(); + } else if ( buffered) { + trace("- buffered transport"); + transfactory = new TBufferedTransportFactory(); + } + + // protocol + var protfactory : TProtocolFactory = null; + switch(prot) + { + case binary: + trace("- binary protocol"); + protfactory = new TBinaryProtocolFactory(); + case json: + trace("- JSON protocol"); + protfactory = new TJSONProtocolFactory(); + default: + throw "Unhandled protocol"; + } + + var handler = new CalculatorHandler(); + var processor = new CalculatorProcessor(handler); + var server = new TSimpleServer( processor, transport, transfactory, protfactory); + #if phpwebserver + server.runOnce = true; + #end + + return server; + } + + + private static function RunServer() : Void { + try + { + var server = ServerSetup(); + + trace("\nStarting the server..."); + server.Serve(); + } + catch( e : Dynamic) + { + trace('RunServer() failed: $e'); + } + trace("done."); + } + +} + -- cgit v1.2.3