All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.funixgaming.api.twitch.service.services.DrakkadesTwitchStreamService Maven / Gradle / Ivy

There is a newer version: 1.3.1.2
Show newest version
package fr.funixgaming.api.twitch.service.services;

import com.funixproductions.api.twitch.reference.client.clients.stream.TwitchStreamsClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
import com.funixproductions.api.twitch.reference.client.dtos.responses.channel.stream.TwitchStreamDTO;
import feign.FeignException;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Slf4j
@Getter
@Service
@RequiredArgsConstructor
public class DrakkadesTwitchStreamService {

    private final TwitchStreamsClient twitchStreamsClient;

    private TwitchDataResponseDTO cacheStream = new TwitchDataResponseDTO<>();

    @Scheduled(fixedDelay = 20, timeUnit = TimeUnit.SECONDS)
    public void fetchStreamInfo() {
        try {
            this.cacheStream = twitchStreamsClient.getStreams("drakkades");
        } catch (FeignException e) {
            log.error("Impossible to fetch stream info from FunixProd APi -> Twitch API. Error code: {}", e.status(), e);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy