1 |
efrain |
1 |
// Copyright 2020 Google LLC
|
|
|
2 |
//
|
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
|
5 |
// You may obtain a copy of the License at
|
|
|
6 |
//
|
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
8 |
//
|
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
12 |
// See the License for the specific language governing permissions and
|
|
|
13 |
// limitations under the License.
|
|
|
14 |
|
|
|
15 |
#import "FirebasePerformance/Sources/Loggers/FPRGDTRateLimiter.h"
|
|
|
16 |
|
|
|
17 |
#import <UIKit/UIKit.h>
|
|
|
18 |
|
|
|
19 |
#import "FirebasePerformance/Sources/Common/FPRPerfDate.h"
|
|
|
20 |
#import "FirebasePerformance/Sources/Configurations/FPRConfigurations.h"
|
|
|
21 |
|
|
|
22 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Extension that is added on top of the class FPRGDTRateLimiter to make the
|
|
|
26 |
* private methods visible between the implementation file and the unit tests.
|
|
|
27 |
*/
|
|
|
28 |
@interface FPRGDTRateLimiter ()
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Number of events that are allowed per minute. This is an internal variable used only for unit
|
|
|
32 |
* testing.
|
|
|
33 |
*/
|
|
|
34 |
@property(nonatomic) CGFloat overrideRate;
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Number of network events that are allowed per minute. This is an internal variable used only for
|
|
|
38 |
* unit testing.
|
|
|
39 |
*/
|
|
|
40 |
@property(nonatomic) CGFloat overrideNetworkRate;
|
|
|
41 |
|
|
|
42 |
/** Number of trace events that can be sent in burst per minute. */
|
|
|
43 |
@property(nonatomic) NSInteger traceEventBurstSize;
|
|
|
44 |
|
|
|
45 |
/** Number of network events that can be sent in burst per minute. */
|
|
|
46 |
@property(nonatomic) NSInteger networkEventburstSize;
|
|
|
47 |
|
|
|
48 |
/** Total number of trace events that are allowed to be sent . */
|
|
|
49 |
@property(nonatomic) NSInteger allowedTraceEventsCount;
|
|
|
50 |
|
|
|
51 |
/** Number of network events that are allowed to be sent . */
|
|
|
52 |
@property(nonatomic) NSInteger allowedNetworkEventsCount;
|
|
|
53 |
|
|
|
54 |
/** Time at which the last trace event was sent. */
|
|
|
55 |
@property(nonatomic) NSDate *lastTraceEventTime;
|
|
|
56 |
|
|
|
57 |
/** Time at which the last network event was sent. */
|
|
|
58 |
@property(nonatomic) NSDate *lastNetworkEventTime;
|
|
|
59 |
|
|
|
60 |
/** @brief Override configurations. */
|
|
|
61 |
@property(nonatomic) FPRConfigurations *configurations;
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Creates an instance of the FPRGDTRateLimiter with the defined date.
|
|
|
65 |
*
|
|
|
66 |
* @param date The date object used for time calculations.
|
|
|
67 |
* @return An instance of the rate limiter.
|
|
|
68 |
*/
|
|
|
69 |
- (instancetype)initWithDate:(id<FPRDate>)date;
|
|
|
70 |
|
|
|
71 |
@end
|
|
|
72 |
|
|
|
73 |
NS_ASSUME_NONNULL_END
|