1 package org.oxerr.seatgeek.client.cached.redisson;
2
3 import java.io.IOException;
4 import java.util.concurrent.Executor;
5 import java.util.concurrent.ForkJoinPool;
6
7 import org.oxerr.seatgeek.client.ListingService;
8 import org.oxerr.seatgeek.client.cached.CachedSeatGeekListingService;
9 import org.oxerr.seatgeek.client.cached.model.SeatGeekEvent;
10 import org.oxerr.seatgeek.client.cached.model.SeatGeekListing;
11 import org.oxerr.seatgeek.client.cached.redisson.model.SeatGeekCachedListing;
12 import org.oxerr.seatgeek.client.model.request.CreateListingRequest;
13 import org.oxerr.ticket.inventory.support.cached.redisson.RedissonCachedListingServiceSupport;
14 import org.oxerr.ticket.inventory.support.cached.redisson.Status;
15 import org.redisson.api.RedissonClient;
16
17 public class RedissonCachedListingService
18 extends RedissonCachedListingServiceSupport<String, String, CreateListingRequest, SeatGeekListing, SeatGeekEvent, SeatGeekCachedListing>
19 implements CachedSeatGeekListingService {
20
21 private final ListingService listingService;
22
23 public RedissonCachedListingService(
24 ListingService listingService,
25 RedissonClient redissonClient,
26 String keyPrefix,
27 boolean create
28 ) {
29 this(listingService, redissonClient, keyPrefix, ForkJoinPool.commonPool(), create);
30 }
31
32 public RedissonCachedListingService(
33 ListingService listingService,
34 RedissonClient redissonClient,
35 String keyPrefix,
36 Executor executor,
37 boolean create
38 ) {
39 super(redissonClient, keyPrefix, executor, create);
40 this.listingService = listingService;
41 }
42
43 protected void deleteListing(SeatGeekEvent event, String ticketId) throws IOException {
44 this.listingService.deleteListing(ticketId);
45 }
46
47 protected void createListing(SeatGeekEvent event, SeatGeekListing listing) throws IOException {
48 this.listingService.createListing(listing.getId(), listing.getRequest());
49 }
50
51 @Override
52 protected SeatGeekCachedListing toCached(SeatGeekEvent event, SeatGeekListing listing, Status status) {
53 return new SeatGeekCachedListing(listing, status);
54 }
55
56 }