Skip to content

Commit 4e4f9ad

Browse files
authored
close #146: websocket implemented (#149)
* Starting websocket * Add security config * Created websocket modules * Started creating a system to handle subscribers * edited MarketStreamHandler * Finish market streams * Finish event streams * Update jenkins script
1 parent 77e4df1 commit 4e4f9ad

79 files changed

Lines changed: 3030 additions & 27 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Api/api-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,6 @@
208208
</executions>
209209
</plugin>
210210
</plugins>
211-
<finalName>opex-accountant</finalName>
211+
<finalName>opex-api</finalName>
212212
</build>
213213
</project>

Api/api-app/src/main/kotlin/co/nilin/opex/app/ApiApp.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
package co.nilin.opex.app
22

3-
import org.springframework.beans.factory.annotation.Value
43
import org.springframework.boot.autoconfigure.SpringBootApplication
54
import org.springframework.boot.runApplication
6-
import org.springframework.context.annotation.Bean
75
import org.springframework.context.annotation.ComponentScan
8-
import org.springframework.security.core.annotation.AuthenticationPrincipal
9-
import springfox.documentation.builders.*
10-
import springfox.documentation.builders.PathSelectors.regex
11-
import springfox.documentation.service.*
12-
import springfox.documentation.spi.DocumentationType
13-
import springfox.documentation.spi.service.contexts.SecurityContext
14-
import springfox.documentation.spring.web.plugins.Docket
15-
import springfox.documentation.swagger.web.SecurityConfiguration
16-
import springfox.documentation.swagger.web.SecurityConfigurationBuilder
176
import springfox.documentation.swagger2.annotations.EnableSwagger2
18-
import java.security.Principal
19-
import java.util.Collections.singletonList
20-
217

228
@SpringBootApplication
239
@ComponentScan("co.nilin.opex")

Api/api-ports/api-binance-rest/src/main/kotlin/co/nilin/opex/port/api/binance/config/SecurityConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class SecurityConfig(private val webClient: WebClient) {
3030
.pathMatchers("/v3/ticker/**").permitAll()
3131
.pathMatchers("/v3/exchangeInfo").permitAll()
3232
.pathMatchers("/v3/klines").permitAll()
33+
.pathMatchers("/socket").permitAll()
3334
.pathMatchers("/**").hasAuthority("SCOPE_trust")
3435
.anyExchange().authenticated()
3536
.and()

Deployment/docker-compose.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,30 @@ services:
306306
deploy:
307307
restart_policy:
308308
condition: on-failure
309-
nginx:
310-
image: jboesl/docker-nginx-headers-more
311-
container_name: opex_nginx
312-
volumes:
313-
- ./nginx.conf:/etc/nginx/nginx.conf
314-
- $DATA/www:/data/www
309+
websocket:
310+
container_name: websocket
311+
build:
312+
context: ../Websocket/websocket-app
313+
dockerfile: Dockerfile
315314
ports:
316-
- 80:80
317-
depends_on:
318-
- wallet
319-
- auth
320-
- matching-gateway
321-
- api
315+
- 127.0.0.1:8097:8097
316+
- 127.0.0.1:1054:1044
317+
environment:
318+
- JAVA_OPTS=-Xmx256m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044
319+
- SPRING_PROFILES_DEFAULT=docker
320+
- KAFKA_IP_PORT=kafka:9092
321+
- CONSUL_HOST=consul
322+
- DB_IP_PORT=postgres-api
322323
networks:
323324
- opex
325+
depends_on:
326+
- zookeeper
327+
- kafka
328+
- consul
329+
- postgres-api
330+
deploy:
331+
restart_policy:
332+
condition: on-failure
324333
bc-gateway:
325334
container_name: bc-gateway
326335
build:
@@ -366,6 +375,21 @@ services:
366375
deploy:
367376
restart_policy:
368377
condition: on-failure
378+
nginx:
379+
image: jboesl/docker-nginx-headers-more
380+
container_name: opex_nginx
381+
volumes:
382+
- ./nginx.conf:/etc/nginx/nginx.conf
383+
- $DATA/www:/data/www
384+
ports:
385+
- 80:80
386+
depends_on:
387+
- wallet
388+
- auth
389+
- matching-gateway
390+
- api
391+
networks:
392+
- opex
369393
networks:
370394
opex:
371395
driver: bridge

Deployment/nginx.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ http {
2727
server storage:8096;
2828
}
2929

30+
upstream docker-websocket {
31+
server storage:8097;
32+
}
33+
3034
proxy_set_header Host $host;
3135
proxy_set_header X-Real-IP $remote_addr;
3236
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -70,6 +74,11 @@ http {
7074
rewrite ^/storage/(.*)$ /$1 break;
7175
}
7276

77+
location /stream {
78+
proxy_pass http://docker-websocket;
79+
rewrite ^/stream/(.*)$ /$1 break;
80+
}
81+
7382
location /api {
7483
proxy_pass http://docker-api;
7584
rewrite ^/api(.*)$ $1 break;

Jenkins/Jenkinsfile.deploy.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ pipeline {
4747
dir("Storage") {
4848
sh 'mvn -B clean install'
4949
}
50+
51+
dir("Websocket") {
52+
sh 'mvn -B clean install'
53+
}
5054
}
5155

5256
}

Websocket/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>co.nilin.opex</groupId>
7+
<artifactId>websocket-root</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<name>websocket-root</name>
10+
<packaging>pom</packaging>
11+
<description>Websocket root module</description>
12+
<modules>
13+
<module>websocket-app</module>
14+
<module>websocket-core</module>
15+
<module>websocket-ports/websocket-eventlistener-kafka</module>
16+
<module>websocket-ports/websocket-persister-postgres</module>
17+
</modules>
18+
</project>

Websocket/websocket-app/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

Websocket/websocket-app/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM openjdk:8-jdk-alpine
2+
VOLUME /tmp
3+
ARG JAR_FILE=target/*.jar
4+
COPY ${JAR_FILE} app.jar
5+
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"]

0 commit comments

Comments
 (0)