2
2
3
3
import static dev .openfeature .contrib .providers .flagd .resolver .process .model .FeatureFlag .EMPTY_TARGETING_STRING ;
4
4
5
- import java .util .Collections ;
6
- import java .util .List ;
7
- import java .util .Map ;
5
+ import java .util .function .Consumer ;
8
6
import java .util .function .Supplier ;
9
7
10
8
import dev .openfeature .contrib .providers .flagd .FlagdOptions ;
11
9
import dev .openfeature .contrib .providers .flagd .resolver .Resolver ;
10
+ import dev .openfeature .contrib .providers .flagd .resolver .common .ConnectionEvent ;
12
11
import dev .openfeature .contrib .providers .flagd .resolver .common .Util ;
13
12
import dev .openfeature .contrib .providers .flagd .resolver .process .model .FeatureFlag ;
14
13
import dev .openfeature .contrib .providers .flagd .resolver .process .storage .FlagStore ;
27
26
import dev .openfeature .sdk .Value ;
28
27
import dev .openfeature .sdk .exceptions .ParseError ;
29
28
import dev .openfeature .sdk .exceptions .TypeMismatchError ;
30
- import dev .openfeature .sdk .internal .TriConsumer ;
31
29
import lombok .extern .slf4j .Slf4j ;
32
30
33
31
/**
38
36
@ Slf4j
39
37
public class InProcessResolver implements Resolver {
40
38
private final Storage flagStore ;
41
- private final TriConsumer < Boolean , List < String >, Map < String , Object > > onConnectionEvent ;
39
+ private final Consumer < ConnectionEvent > onConnectionEvent ;
42
40
private final Operator operator ;
43
41
private final long deadline ;
44
42
private final ImmutableMetadata metadata ;
@@ -56,7 +54,7 @@ public class InProcessResolver implements Resolver {
56
54
* connection/stream
57
55
*/
58
56
public InProcessResolver (FlagdOptions options , final Supplier <Boolean > connectedSupplier ,
59
- TriConsumer < Boolean , List < String >, Map < String , Object > > onConnectionEvent ) {
57
+ Consumer < ConnectionEvent > onConnectionEvent ) {
60
58
this .flagStore = new FlagStore (getConnector (options ));
61
59
this .deadline = options .getDeadline ();
62
60
this .onConnectionEvent = onConnectionEvent ;
@@ -79,11 +77,11 @@ public void init() throws Exception {
79
77
final StorageStateChange storageStateChange = flagStore .getStateQueue ().take ();
80
78
switch (storageStateChange .getStorageState ()) {
81
79
case OK :
82
- onConnectionEvent .accept (true , storageStateChange .getChangedFlagsKeys (),
83
- storageStateChange .getSyncMetadata ());
80
+ onConnectionEvent .accept (new ConnectionEvent ( true , storageStateChange .getChangedFlagsKeys (),
81
+ storageStateChange .getSyncMetadata ())) ;
84
82
break ;
85
83
case ERROR :
86
- onConnectionEvent .accept (false , Collections . emptyList (), Collections . emptyMap ( ));
84
+ onConnectionEvent .accept (new ConnectionEvent ( false ));
87
85
break ;
88
86
default :
89
87
log .info (String .format ("Storage emitted unhandled status: %s" ,
@@ -109,7 +107,7 @@ public void init() throws Exception {
109
107
*/
110
108
public void shutdown () throws InterruptedException {
111
109
flagStore .shutdown ();
112
- onConnectionEvent .accept (false , Collections . emptyList (), Collections . emptyMap ( ));
110
+ onConnectionEvent .accept (new ConnectionEvent ( false ));
113
111
}
114
112
115
113
/**
0 commit comments