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

wz2cool / local-queue / #21

30 Jan 2025 07:56AM UTC coverage: 91.466% (-1.0%) from 92.442%
#21

push

web-flow
Merge pull request #4 from wz2cool/0.1.0

0.1.0

154 of 174 new or added lines in 10 files covered. (88.51%)

6 existing lines in 2 files now uncovered.

418 of 457 relevant lines covered (91.47%)

0.91 hits per line

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

91.23
/src/main/java/com/github/wz2cool/localqueue/model/config/SimpleConsumerConfig.java
1
package com.github.wz2cool.localqueue.model.config;
2

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

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

8
public class SimpleConsumerConfig {
9

10
    private final File dataDir;
11

12
    private final File positionFile;
13

14
    private final String consumerId;
15

16
    private final long pullInterval;
17

18
    private final long fillCacheInterval;
19

20
    private final int cacheSize;
21

22
    private final long flushPositionInterval;
23

24
    private final ConsumeFromWhere consumeFromWhere;
25

26
    private SimpleConsumerConfig(final Builder builder) {
1✔
27
        this.dataDir = builder.dataDir;
1✔
28
        this.positionFile = builder.positionFile;
1✔
29
        this.consumerId = builder.consumerId;
1✔
30
        this.pullInterval = builder.pullInterval;
1✔
31
        this.fillCacheInterval = builder.fillCacheInterval;
1✔
32
        this.cacheSize = builder.cacheSize;
1✔
33
        this.flushPositionInterval = builder.flushPositionInterval;
1✔
34
        this.consumeFromWhere = builder.consumeFromWhere;
1✔
35
    }
1✔
36

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

41
    public File getPositionFile() {
42
        return positionFile;
1✔
43
    }
44

45
    public String getConsumerId() {
46
        return consumerId;
1✔
47
    }
48

49
    public long getPullInterval() {
50
        return pullInterval;
1✔
51
    }
52

53
    public int getCacheSize() {
54
        return cacheSize;
1✔
55
    }
56

57
    public long getFlushPositionInterval() {
58
        return flushPositionInterval;
1✔
59
    }
60

61
    public ConsumeFromWhere getConsumeFromWhere() {
62
        return consumeFromWhere;
1✔
63
    }
64

65
    public long getFillCacheInterval() {
66
        return fillCacheInterval;
1✔
67
    }
68

69
    public static class Builder {
1✔
70

71
        private File dataDir;
72

73
        private File positionFile;
74

75
        private String consumerId;
76

77
        private long pullInterval = 10;
1✔
78

79
        private int cacheSize = 10000;
1✔
80

81
        private long fillCacheInterval = 500;
1✔
82

83
        private long flushPositionInterval = 100;
1✔
84

85
        private ConsumeFromWhere consumeFromWhere = ConsumeFromWhere.LAST;
1✔
86

87
        public Builder setDataDir(File dataDir) {
88
            this.dataDir = dataDir;
1✔
89
            return this;
1✔
90
        }
91

92
        public Builder setPositionFile(File positionFile) {
93
            this.positionFile = positionFile;
1✔
94
            return this;
1✔
95
        }
96

97
        public Builder setConsumerId(String consumerId) {
98
            this.consumerId = consumerId;
1✔
99
            return this;
1✔
100
        }
101

102
        public Builder setPullInterval(long pullInterval) {
103
            this.pullInterval = pullInterval;
1✔
104
            return this;
1✔
105
        }
106

107
        public Builder setCacheSize(int cacheSize) {
108
            this.cacheSize = cacheSize;
1✔
109
            return this;
1✔
110
        }
111

112
        public Builder setFlushPositionInterval(long flushPositionInterval) {
113
            this.flushPositionInterval = flushPositionInterval;
1✔
114
            return this;
1✔
115
        }
116

117
        public Builder setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
118
            this.consumeFromWhere = consumeFromWhere;
1✔
119
            return this;
1✔
120
        }
121

122
        public Builder setFillCacheInterval(long fillCacheInterval) {
NEW
123
            this.fillCacheInterval = fillCacheInterval;
×
NEW
124
            return this;
×
125
        }
126

127
        public SimpleConsumerConfig build() {
128
            if (Objects.isNull(dataDir)) {
1✔
129
                throw new IllegalArgumentException("dataDir cannot be null");
1✔
130
            }
131

132
            if (Objects.isNull(consumerId) || consumerId.isEmpty()) {
1✔
133
                // 如果没有就给默认
134
                throw new IllegalArgumentException("consumerId cannot be null or empty");
1✔
135
            }
136

137
            if (cacheSize <= 0) {
1✔
138
                throw new IllegalArgumentException("cacheSize should > 0");
1✔
139
            }
140

141
            if (flushPositionInterval <= 0) {
1✔
142
                throw new IllegalArgumentException("flushPositionInterval should > 0");
1✔
143
            }
144

145
            if (Objects.isNull(positionFile)) {
1✔
146
                // 如果没有就给默认
147
                this.positionFile = new File(dataDir, "position.dat");
1✔
148
            }
149

150
            if (Objects.isNull(consumeFromWhere)) {
1✔
NEW
151
                throw new IllegalArgumentException("consumeFromWhere cannot be null");
×
152
            }
153

154
            if (pullInterval <= 0) {
1✔
NEW
155
                throw new IllegalArgumentException("pullInterval should > 0");
×
156
            }
157

158
            if (fillCacheInterval <= 0) {
1✔
NEW
159
                throw new IllegalArgumentException("fillCacheInterval should > 0");
×
160
            }
161

162
            return new SimpleConsumerConfig(this);
1✔
163
        }
164

165
    }
166
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc