birdmonger 0.1.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ [ ParaNamer used to be 'Pubic Domain', but since it includes a small piece of ASM it is now the same license as that: BSD ]
2
+
3
+ Copyright (c) 2006 Paul Hammant & ThoughtWorks Inc
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions
8
+ are met:
9
+ 1. Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+ 3. Neither the name of the copyright holders nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28
+ THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2018 Iikka Niinivaara
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ * may not use this file except in compliance with the License. You may
6
+ * obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ * implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ import sbt._
18
+
19
+ object Dependencies {
20
+ lazy val twitterServer = "com.twitter" %% "twitter-server" % "18.2.0"
21
+ lazy val slf4jSimple = "org.slf4j" % "slf4j-simple" % "1.7.21"
22
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2018 Iikka Niinivaara
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ * may not use this file except in compliance with the License. You may
6
+ * obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ * implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
@@ -0,0 +1 @@
1
+ sbt.version=1.1.1
@@ -0,0 +1,81 @@
1
+ /*
2
+ * Copyright (c) 2018 Iikka Niinivaara
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ * may not use this file except in compliance with the License. You may
6
+ * obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ * implied. See the License for the specific language governing
14
+ * permissions and limitations under the License.
15
+ */
16
+
17
+ package birdmonger
18
+
19
+ import java.net.InetSocketAddress
20
+
21
+ import collection.JavaConverters._
22
+ import com.twitter.finagle.{Http, ListeningServer, Service}
23
+ import com.twitter.finagle.http.{Request, Response}
24
+ import com.twitter.server.TwitterServer
25
+ import com.twitter.util.{Await, Future}
26
+
27
+ object Server extends TwitterServer {
28
+ private val startServer = flag("birdmonger.startServer", true, "Should we actually start listening for connections")
29
+ private val endpoint = flag("birdmonger.endpoint", new InetSocketAddress("localhost", 3000), "Host and port to listen on")
30
+ private val certificatePath = flag[String]("birdmonger.tls.certificatePath", "", "The path to the PEM encoded X.509 certificate chain. Required for TLS")
31
+ private val keyPath = flag[String]("birdmonger.tls.keyPath", "", "The path to the corresponding PEM encoded PKCS#8 private key. Required for TLS")
32
+ private val caCertificatePath = flag[String]("birdmonger.tls.caCertificatePath", "", "The path to the optional PEM encoded CA certificates trusted by this server")
33
+ private val ciphers = flag[String]("birdmonger.tls.ciphers", "", "Ciphers the list of supported ciphers, delimited by `:`")
34
+ private val nextProtocols = flag[String]("birdmonger.tls.nextProtocols", "", "The comma-delimited list of protocols used to perform APN (Application Protocol Negotiation)")
35
+ private var useHTTPS = false
36
+
37
+ var handler: (Request, java.util.Map[String, String]) => Response = _
38
+
39
+ val service: Service[Request, Response] {
40
+ def apply(request: Request): Future[Response]
41
+ } = new Service[Request, Response] {
42
+ def apply(request: Request): Future[Response] = {
43
+ Future.value(handler(request, request.headerMap.asJava))
44
+ }
45
+ }
46
+
47
+ def apply: ListeningServer = {
48
+ var serverConf = Http.server
49
+ .configured(Http.Netty4Impl)
50
+
51
+ if (certificatePath.isDefined || keyPath.isDefined) {
52
+ serverConf = serverConf.withTransport.tls(certificatePath(), keyPath(), caCertificatePath.get, ciphers.get, nextProtocols.get)
53
+ useHTTPS = true
54
+ }
55
+
56
+ val server = serverConf.serve(endpoint(), service)
57
+ server
58
+ }
59
+
60
+ def main(): Unit = {
61
+ if (startServer()) {
62
+ val server: ListeningServer = apply
63
+
64
+ onExit {
65
+ server.close()
66
+ }
67
+
68
+ Await.ready(server)
69
+ }
70
+ }
71
+
72
+ def scheme(): String = {
73
+ if (useHTTPS) {
74
+ "https"
75
+ } else {
76
+ "http"
77
+ }
78
+ }
79
+
80
+
81
+ }
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: birdmonger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - Iikka Niinivaara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.16'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '12.0'
33
+ name: rake
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 3.7.0
47
+ name: rspec
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.6.4
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.1'
64
+ name: rack
65
+ prerelease: false
66
+ type: :runtime
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.6.4
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.1'
75
+ description: TwitterServer-based Rack handler
76
+ email:
77
+ - mebe@habeeb.it
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE
86
+ - NOTICE
87
+ - README.md
88
+ - Rakefile
89
+ - birdmonger.gemspec
90
+ - build.sbt
91
+ - lib/birdmonger.jar
92
+ - lib/birdmonger.rb
93
+ - lib/birdmonger/version.rb
94
+ - lib/rack/handler/birdmonger.rb
95
+ - licenses/LICENSE-Caffeine.txt
96
+ - licenses/LICENSE-HdrHistogram.txt
97
+ - licenses/LICENSE-JSR305.txt
98
+ - licenses/LICENSE-SLF4J.txt
99
+ - licenses/LICENSE-Scala.txt
100
+ - licenses/LICENSE-TwitterServer.txt
101
+ - licenses/LICENSE-Util.txt
102
+ - licenses/LICENSE-paranamer.txt
103
+ - project/Dependencies.scala
104
+ - project/assembly.sbt
105
+ - project/build.properties
106
+ - src/main/scala/birdmonger/Server.scala
107
+ homepage: https://github.com/mebe/birdmonger
108
+ licenses: []
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.6.14
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: TwitterServer-based Rack handler
130
+ test_files: []