Skip to content

Commit eba3402

Browse files
docs: fix inaccuracies in README code examples
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
1 parent b683371 commit eba3402

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ If the flag management system you're using supports targeting, you can provide t
217217
// set a value to the global context
218218
OpenFeatureAPI api = OpenFeatureAPI.getInstance();
219219
Map<String, Value> apiAttrs = new HashMap<>();
220-
apiAttrs.put("region", new Value(System.getEnv("us-east-1")));
220+
apiAttrs.put("region", new Value(System.getenv("AWS_REGION")));
221221
EvaluationContext apiCtx = new ImmutableContext(apiAttrs);
222222
api.setEvaluationContext(apiCtx);
223223

224224
// set a value to the client context
225225
Map<String, Value> clientAttrs = new HashMap<>();
226-
clientAttrs.put("region", new Value(System.getEnv("us-east-1")));
226+
clientAttrs.put("region", new Value(System.getenv("AWS_REGION")));
227227
EvaluationContext clientCtx = new ImmutableContext(clientAttrs);
228-
Client client = api.getInstance().getClient();
228+
Client client = api.getClient();
229229
client.setEvaluationContext(clientCtx);
230230

231231
// set a value to the invocation context
@@ -292,7 +292,7 @@ If a domain has no associated provider, the global provider is used.
292292
FeatureProvider scopedProvider = new MyProvider();
293293

294294
// registering the default provider
295-
OpenFeatureAPI.getInstance().setProvider(LocalProvider());
295+
OpenFeatureAPI.getInstance().setProvider(new LocalProvider());
296296
// registering a provider to a domain
297297
OpenFeatureAPI.getInstance().setProvider("my-domain", new CachedProvider());
298298

@@ -452,25 +452,26 @@ This can be a new repository or included in [the existing contrib repository](ht
452452
Implement your own hook by conforming to the `Hook interface`.
453453

454454
```java
455-
class MyHook implements Hook {
455+
class MyHook implements Hook<Object> {
456456

457457
@Override
458-
public Optional before(HookContext ctx, Map hints) {
458+
public Optional<EvaluationContext> before(HookContext<Object> ctx, Map<String, Object> hints) {
459459
// code that runs before the flag evaluation
460+
return Optional.empty();
460461
}
461462

462463
@Override
463-
public void after(HookContext ctx, FlagEvaluationDetails details, Map hints) {
464+
public void after(HookContext<Object> ctx, FlagEvaluationDetails<Object> details, Map<String, Object> hints) {
464465
// code that runs after the flag evaluation succeeds
465466
}
466467

467468
@Override
468-
public void error(HookContext ctx, Exception error, Map hints) {
469+
public void error(HookContext<Object> ctx, Exception error, Map<String, Object> hints) {
469470
// code that runs when there's an error during a flag evaluation
470471
}
471472

472473
@Override
473-
public void finallyAfter(HookContext ctx, FlagEvaluationDetails details, Map hints) {
474+
public void finallyAfter(HookContext<Object> ctx, FlagEvaluationDetails<Object> details, Map<String, Object> hints) {
474475
// code that runs regardless of success or error
475476
}
476477
};

0 commit comments

Comments
 (0)