-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
SendFireAndForgetOutboxSender.java
48 lines (39 loc) · 1.7 KB
/
SendFireAndForgetOutboxSender.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package io.sentry;
import io.sentry.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ApiStatus.Internal
public final class SendFireAndForgetOutboxSender
implements SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForgetFactory {
private final @NotNull SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForgetDirPath
sendFireAndForgetDirPath;
public SendFireAndForgetOutboxSender(
final @NotNull SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForgetDirPath
sendFireAndForgetDirPath) {
this.sendFireAndForgetDirPath =
Objects.requireNonNull(sendFireAndForgetDirPath, "SendFireAndForgetDirPath is required");
}
@Override
public @Nullable SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForget create(
final @NotNull IHub hub, final @NotNull SentryOptions options) {
Objects.requireNonNull(hub, "Hub is required");
Objects.requireNonNull(options, "SentryOptions is required");
final String dirPath = sendFireAndForgetDirPath.getDirPath();
if (dirPath == null || !hasValidPath(dirPath, options.getLogger())) {
options.getLogger().log(SentryLevel.ERROR, "No outbox dir path is defined in options.");
return null;
}
final OutboxSender outboxSender =
new OutboxSender(
hub,
options.getEnvelopeReader(),
options.getSerializer(),
options.getLogger(),
options.getFlushTimeoutMillis());
return processDir(outboxSender, dirPath, options.getLogger());
}
@Override public @Nullable String getDirPath() {
return sendFireAndForgetDirPath.getDirPath();
}
}