добавлена таблица task_queue, для постановки в очередь задач
This commit is contained in:
parent
9fbbfdb697
commit
6ef83e9511
|
|
@ -1,36 +0,0 @@
|
||||||
services:
|
|
||||||
|
|
||||||
zookeeper:
|
|
||||||
image: confluentinc/cp-zookeeper:7.6.1
|
|
||||||
container_name: zookeeper
|
|
||||||
environment:
|
|
||||||
ZOOKEEPER_CLIENT_PORT: 2181
|
|
||||||
ZOOKEEPER_TICK_TIME: 2000
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
kafka:
|
|
||||||
image: confluentinc/cp-kafka:7.6.1
|
|
||||||
container_name: kafka
|
|
||||||
depends_on:
|
|
||||||
- zookeeper
|
|
||||||
ports:
|
|
||||||
- "29092:29092"
|
|
||||||
environment:
|
|
||||||
KAFKA_BROKER_ID: 1
|
|
||||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
|
||||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
|
|
||||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
|
||||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
||||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
||||||
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
||||||
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres_data:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
lti-net:
|
|
||||||
driver: bridge
|
|
||||||
default:
|
|
||||||
name: lti-net
|
|
||||||
|
|
@ -18,32 +18,6 @@ services:
|
||||||
retries: 5
|
retries: 5
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
zookeeper:
|
|
||||||
image: confluentinc/cp-zookeeper:7.6.1
|
|
||||||
container_name: zookeeper
|
|
||||||
environment:
|
|
||||||
ZOOKEEPER_CLIENT_PORT: 2181
|
|
||||||
ZOOKEEPER_TICK_TIME: 2000
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
kafka:
|
|
||||||
image: confluentinc/cp-kafka:7.6.1
|
|
||||||
container_name: kafka
|
|
||||||
depends_on:
|
|
||||||
- zookeeper
|
|
||||||
ports:
|
|
||||||
- "29092:29092"
|
|
||||||
environment:
|
|
||||||
KAFKA_BROKER_ID: 1
|
|
||||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
|
||||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
|
|
||||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
|
||||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
||||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
||||||
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
|
|
||||||
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,4 +39,20 @@ public class ApplicationService {
|
||||||
return "Not Page";
|
return "Not Page";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String saveResult(String body) {
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
return "{\n" +
|
||||||
|
" \"success\": true,\n" +
|
||||||
|
" \"message\": \"Результат успешно получен и обработан\",\n" +
|
||||||
|
" \"data\": {\n" +
|
||||||
|
" \"contextId\": \"ctx-12345\",\n" +
|
||||||
|
" \"participantId\": \"usr-67890\",\n" +
|
||||||
|
" \"submittedText\": \"console.log('Hello');\",\n" +
|
||||||
|
" \"timestamp\": \"2025-12-14T17:55:30Z\",\n" +
|
||||||
|
" \"status\": \"processed\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,28 +5,25 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import ru.oa2.lti.ApplicationService;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/tool/result")
|
@RequestMapping("/tool/result")
|
||||||
public class ResultController {
|
public class ResultController {
|
||||||
|
|
||||||
|
final ApplicationService service;
|
||||||
|
|
||||||
|
public ResultController(ApplicationService applicationService) {
|
||||||
|
this.service = applicationService;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/docker")
|
@PostMapping("/docker")
|
||||||
public String result(@RequestBody String body) {
|
public String result(@RequestBody String body) {
|
||||||
|
|
||||||
log.info("RESULT: {}", body);
|
log.info("RESULT: {}", body);
|
||||||
|
|
||||||
//TODO
|
//TODO возвращать json
|
||||||
return "{\n" +
|
return service.saveResult(body);
|
||||||
" \"success\": true,\n" +
|
|
||||||
" \"message\": \"Результат успешно получен и обработан\",\n" +
|
|
||||||
" \"data\": {\n" +
|
|
||||||
" \"contextId\": \"ctx-12345\",\n" +
|
|
||||||
" \"participantId\": \"usr-67890\",\n" +
|
|
||||||
" \"submittedText\": \"console.log('Hello');\",\n" +
|
|
||||||
" \"timestamp\": \"2025-12-14T17:55:30Z\",\n" +
|
|
||||||
" \"status\": \"processed\"\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package ru.oa2.lti.model;
|
||||||
|
|
||||||
|
public enum TaskQueueStatus {
|
||||||
|
NEW,
|
||||||
|
RUNNING,
|
||||||
|
ERROR,
|
||||||
|
FINISHED
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,5 @@ import java.util.UUID;
|
||||||
@Repository
|
@Repository
|
||||||
public interface LMSContentRepository extends JpaRepository<LMSContent, Long> {
|
public interface LMSContentRepository extends JpaRepository<LMSContent, Long> {
|
||||||
|
|
||||||
Optional<LMSContent> getLMSContentByContentKey(long id);
|
|
||||||
Optional<LMSContent> getLMSContentByContentId(UUID contentId);
|
Optional<LMSContent> getLMSContentByContentId(UUID contentId);
|
||||||
Optional<LMSContent> findByContentId(UUID contentId);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ru.oa2.lti.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import ru.oa2.lti.repository.entities.TaskQueue;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface TaskQueueRepository extends JpaRepository<TaskQueue, Long> {
|
||||||
|
}
|
||||||
|
|
@ -2,11 +2,12 @@ package ru.oa2.lti.repository.entities;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
@Getter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "lms_content")
|
@Table(name = "lms_content")
|
||||||
public class LMSContent {
|
public class LMSContent {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package ru.oa2.lti.repository.entities;
|
package ru.oa2.lti.repository.entities;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
import ru.oa2.lti.model.TaskType;
|
import ru.oa2.lti.model.TaskType;
|
||||||
|
|
||||||
@Data
|
@Getter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "task")
|
@Table(name = "task")
|
||||||
public class Task {
|
public class Task {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package ru.oa2.lti.repository.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import ru.oa2.lti.model.TaskQueueStatus;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "task_queue")
|
||||||
|
public class TaskQueue {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
Long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "task_id", nullable = false)
|
||||||
|
Task taskId;
|
||||||
|
|
||||||
|
@Column(name = "content", columnDefinition = "jsonb")
|
||||||
|
Object content;
|
||||||
|
|
||||||
|
@Column(name = "status")
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
TaskQueueStatus status;
|
||||||
|
|
||||||
|
@Column(name = "finished")
|
||||||
|
Boolean finished;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd"
|
||||||
|
objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">
|
||||||
|
|
||||||
|
<changeSet id="2025-12-01" author="dzyk">
|
||||||
|
|
||||||
|
<createTable tableName="task_queue">
|
||||||
|
|
||||||
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_TASK_QUEUE"/>
|
||||||
|
</column>
|
||||||
|
|
||||||
|
<column name="task_id" type="bigint"/>
|
||||||
|
|
||||||
|
<column name="content" type="jsonb"/>
|
||||||
|
|
||||||
|
<column name="status" type="varchar(20)"/>
|
||||||
|
|
||||||
|
<column name="finished" type="boolean"/>
|
||||||
|
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="task_queue"
|
||||||
|
baseColumnNames="task_id"
|
||||||
|
constraintName="fk_task_queue_task"
|
||||||
|
referencedTableName="task"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
onDelete="NO ACTION"/>
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
|
|
@ -10,5 +10,6 @@
|
||||||
|
|
||||||
<include file="/db/changelog/1.0.0/2025-12-add_task.xml"/>
|
<include file="/db/changelog/1.0.0/2025-12-add_task.xml"/>
|
||||||
<include file="/db/changelog/1.0.0/2025-12-add_lms_content.xml"/>
|
<include file="/db/changelog/1.0.0/2025-12-add_lms_content.xml"/>
|
||||||
|
<include file="/db/changelog/1.0.0/2025-12-add_task_queue.xml"/>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
Loading…
Reference in New Issue