-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
128 lines (98 loc) · 3.36 KB
/
types.go
File metadata and controls
128 lines (98 loc) · 3.36 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package ripple
import (
"fmt"
"time"
"github.com/Tap30/ripple-go/adapters"
)
// Re-export adapter types for convenience
type (
// Event represents a trackable analytics event.
Event = adapters.Event
// EventMetadata contains optional metadata associated with an event.
EventMetadata = adapters.EventMetadata
// Platform describes the runtime environment (e.g., server, client).
Platform = adapters.Platform
// HTTPAdapter defines the interface used by the client to perform HTTP requests.
HTTPAdapter = adapters.HTTPAdapter
// HTTPResponse represents a response returned by an HTTPAdapter.
HTTPResponse = adapters.HTTPResponse
// StorageAdapter defines the interface used for event persistence and retries.
StorageAdapter = adapters.StorageAdapter
// LoggerAdapter defines the interface used for internal SDK logging.
LoggerAdapter = adapters.LoggerAdapter
// LogLevel represents the severity level for logging.
LogLevel = adapters.LogLevel
// StorageQuotaExceededError indicates that the storage quota has been exceeded.
StorageQuotaExceededError = adapters.StorageQuotaExceededError
)
// HTTPError represents an HTTP error response.
// Can be used by custom HTTPAdapter implementations to wrap HTTP errors.
type HTTPError struct {
Status int
}
func (e *HTTPError) Error() string {
return fmt.Sprintf("HTTP request failed with status %d", e.Status)
}
type ClientConfig struct {
// APIKey is the authentication key used to authorize requests.
//
// Required.
APIKey string
// Endpoint is the base HTTPS URL of the Ripple API.
//
// Example: https://api.ripple.io
//
// Required.
Endpoint string
// APIKeyHeader is the HTTP header name used to send the API key.
//
// Default: "X-API-Key"
APIKeyHeader *string
// FlushInterval controls how often events are automatically flushed
// to the server.
//
// Default: 5 seconds.
FlushInterval time.Duration
// MaxBatchSize is the maximum number of events sent in a single request.
//
// Default: 10.
MaxBatchSize int
// MaxRetries is the maximum number of retry attempts for failed requests.
//
// Default: 3.
MaxRetries int
// HTTPAdapter is the transport layer used to perform HTTP requests.
//
// Required.
HTTPAdapter HTTPAdapter
// StorageAdapter is used to persist events for retry and durability.
//
// Required.
StorageAdapter StorageAdapter
// LoggerAdapter is used for internal SDK logging.
//
// Default: PrintLoggerAdapter with WARN level.
LoggerAdapter LoggerAdapter
// MaxBufferSize is the maximum number of events to persist to storage.
// When limit is exceeded, oldest events are evicted using FIFO policy.
//
// Optional: If not set or 0, no limit is applied.
MaxBufferSize int
}
type DispatcherConfig struct {
// APIKey is the authentication key used to authorize requests.
APIKey string
// APIKeyHeader is the HTTP header name used to send the API key.
APIKeyHeader string
// Endpoint is the base HTTPS URL of the Ripple API.
Endpoint string
// FlushInterval controls how often queued events are flushed.
FlushInterval time.Duration
// MaxBatchSize is the maximum number of events per batch.
MaxBatchSize int
// MaxRetries is the maximum number of retry attempts for failed requests.
MaxRetries int
// MaxBufferSize is the maximum number of events to persist to storage.
// When limit is exceeded, oldest events are evicted using FIFO policy.
MaxBufferSize int
}