Skip to content

Commit

Permalink
chore: setup conjob on api
Browse files Browse the repository at this point in the history
  • Loading branch information
nemo83 committed Feb 2, 2024
1 parent 1753414 commit 2dedc3e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.cardanofoundation.metadatatools</groupId>
<artifactId>common</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.cardanofoundation.metadatatools</groupId>
<artifactId>core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.List;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "org.cardanofoundation.tokenmetadata.registry")
public class TokenMetadataRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(TokenMetadataRegistryApplication.class, args);
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ spring.flyway.schemas=${DB_SCHEMA:public}
spring.flyway.baselineOnMigrate=true
spring.flyway.enabled=true
spring.flyway.validateMigrationNaming=true

# Github Token Metadata Sync
token.metadata.job.enabled=${TOKEN_METADATA_SYNC:true}
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
package org.cardanofoundation.tokenmetadata.registry.service;

import jakarta.annotation.PostConstruct;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.cardanofoundation.tokenmetadata.registry.model.Mapping;
import org.cardanofoundation.tokenmetadata.registry.model.MappingDetails;
import org.cardanofoundation.tokenmetadata.registry.model.MappingUpdateDetails;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Conditional;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

@Service
@Slf4j
@AllArgsConstructor
@ConditionalOnProperty(prefix = "token.metadata.job", value = "enabled", havingValue = "true")
public class TokenMetadataSyncCronJob implements Runnable{
public class TokenMetadataSyncCronJob implements Runnable {

private final TokenMetadataSyncService tokenMetadataSyncService;

@Override
@Scheduled(timeUnit = TimeUnit.MINUTES, initialDelay = 1L, fixedDelay = 60L)
public void run() {
log.info("about to start syncing");
tokenMetadataSyncService.synchronizeDatabase();
log.info("syncing completed");
}


@PostConstruct
public void logInitMessage() {
log.info("Cronjob initialised");
}

}

0 comments on commit 2dedc3e

Please sign in to comment.