• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wz2cool / local-queue / #35

01 Feb 2025 11:33AM UTC coverage: 91.85% (-0.07%) from 91.919%
#35

push

wz2cool
support timezone

44 of 48 new or added lines in 7 files covered. (91.67%)

586 of 638 relevant lines covered (91.85%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/src/main/java/com/github/wz2cool/localqueue/model/config/SimpleProducerConfig.java
1
package com.github.wz2cool.localqueue.model.config;
2

3
import com.github.wz2cool.localqueue.model.enums.RollCycleType;
4

5
import java.io.File;
6
import java.util.Objects;
7
import java.util.TimeZone;
8

9
/**
10
 * the config of producer
11
 *
12
 * @author frank
13
 */
14
public class SimpleProducerConfig {
15

16
    private final File dataDir;
17
    // -1 表示不删除
18
    private final int keepDays;
19

20
    private final int flushBatchSize;
21

22
    private final long flushInterval;
23

24
    private final RollCycleType rollCycleType;
25

26
    private final TimeZone timeZone;
27

28
    private SimpleProducerConfig(Builder builder) {
1✔
29
        this.dataDir = builder.dataDir;
1✔
30
        this.keepDays = builder.keepDays;
1✔
31
        this.flushBatchSize = builder.flushBatchSize;
1✔
32
        this.flushInterval = builder.flushInterval;
1✔
33
        this.rollCycleType = builder.rollCycleType;
1✔
34
        this.timeZone = builder.timeZone;
1✔
35
    }
1✔
36

37
    public File getDataDir() {
38
        return dataDir;
1✔
39
    }
40

41
    public int getKeepDays() {
42
        return keepDays;
1✔
43
    }
44

45
    public int getFlushBatchSize() {
46
        return flushBatchSize;
1✔
47
    }
48

49
    public long getFlushInterval() {
50
        return flushInterval;
1✔
51
    }
52

53
    public RollCycleType getRollCycleType() {
54
        return rollCycleType;
1✔
55
    }
56

57
    public TimeZone getTimeZone() {
58
        return timeZone;
1✔
59
    }
60

61
    public static class Builder {
1✔
62
        private File dataDir;
63
        private int keepDays = -1;
1✔
64
        private int flushBatchSize = 1000;
1✔
65
        private long flushInterval = 10;
1✔
66
        private RollCycleType rollCycleType = RollCycleType.HOURLY;
1✔
67
        private TimeZone timeZone = TimeZone.getDefault();
1✔
68

69
        public Builder setDataDir(File dataDir) {
70
            this.dataDir = dataDir;
1✔
71
            return this;
1✔
72
        }
73

74
        public Builder setKeepDays(int keepDays) {
75
            this.keepDays = keepDays;
1✔
76
            return this;
1✔
77
        }
78

79
        public Builder setFlushBatchSize(int flushBatchSize) {
80
            this.flushBatchSize = flushBatchSize;
1✔
81
            return this;
1✔
82
        }
83

84
        public Builder setFlushInterval(long flushInterval) {
85
            this.flushInterval = flushInterval;
1✔
86
            return this;
1✔
87
        }
88

89
        public Builder setRollCycleType(RollCycleType rollCycleType) {
90
            this.rollCycleType = rollCycleType;
1✔
91
            return this;
1✔
92
        }
93

94
        public Builder setTimeZone(TimeZone timeZone) {
95
            this.timeZone = timeZone;
1✔
96
            return this;
1✔
97
        }
98

99
        public SimpleProducerConfig build() {
100
            if (Objects.isNull(dataDir)) {
1✔
101
                throw new IllegalArgumentException("dataDir cannot be null");
1✔
102
            }
103
            if (flushBatchSize <= 0) {
1✔
104
                throw new IllegalArgumentException("flushBatchSize should > 0");
1✔
105
            }
106
            if (flushInterval <= 0) {
1✔
107
                throw new IllegalArgumentException("flushInterval should > 0");
×
108
            }
109
            if (Objects.isNull(rollCycleType)) {
1✔
NEW
110
                throw new IllegalArgumentException("rollCycleType cannot be null");
×
111
            }
112
            if (Objects.isNull(timeZone)) {
1✔
NEW
113
                throw new IllegalArgumentException("timeZone cannot be null");
×
114
            }
115

116
            return new SimpleProducerConfig(this);
1✔
117
        }
118
    }
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc