Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-chu committed Jan 6, 2025
1 parent 824c50d commit 32b1ea0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import com.ghostchu.btn.sparkle.util.ByteUtil;
import com.ghostchu.btn.sparkle.util.paging.SparklePage;
import io.micrometer.core.instrument.MeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
Expand All @@ -19,6 +21,7 @@
import java.util.Collection;

@Service
@Slf4j
public class ClientDiscoveryService {
private final ClientDiscoveryRepository clientDiscoveryRepository;
@Autowired
Expand All @@ -29,10 +32,15 @@ public ClientDiscoveryService(ClientDiscoveryRepository clientDiscoveryRepositor
}

@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED)
@Async
public void handleIdentities(OffsetDateTime timeForFoundAt, OffsetDateTime timeForLastSeenAt, Collection<ClientIdentity> clientIdentities) {
meterRegistry.counter("sparkle_client_discovery_processed").increment();
for (ClientIdentity ci : clientIdentities) {
clientDiscoveryRepository.saveIgnoreConflict(ci.hash(), ByteUtil.filterUTF8(ci.getClientName()), ByteUtil.filterUTF8(ci.getPeerId()), timeForFoundAt);
try {
clientDiscoveryRepository.saveIgnoreConflict(ci.hash(), ByteUtil.filterUTF8(ci.getClientName()), ByteUtil.filterUTF8(ci.getPeerId()), timeForFoundAt);
} catch (Exception e) {
log.error("Failed to save client discovery: {}:{}", e.getClass().getName(), e.getMessage());
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definiti
spring.jpa.properties.hibernate.session_factory.stateless.enabled=true
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.jdbc.batch_size=2000
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
spring.jpa.properties.hibernate.generate_statistics=false
spring.data.redis.host=localhost
spring.data.redis.port=6379
Expand Down

0 comments on commit 32b1ea0

Please sign in to comment.