2

I am currently looking at implementing feature toggles using ff4j for our application. We want to have a remote central config app which will hold all the features in it and the applications will talk to this central config app via REST to get the features. We will not be able to leverage Spring Cloud Config or Archaius for this purpose.

I went through the documentation and it seems there is a support for HttpClient (https://github.com/ff4j/ff4j/wiki/Store-Technologies#httpclient). But I couldn't find any sample for the same. Can someone please let me know if I can leverage this method to build my feature store from a REST endpoint. Also, I would appreciate if someone could point me to a sample of this.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Anoop
  • 813
  • 2
  • 10
  • 24

1 Answers1

2

This is a common pattern.

  1. A component holds the Administration UI (console) and the REST API. You can call it the "Admin Component". For security reasons It may be the only component to have access to persistance unit (any of the 15 DB implementation available)

For the "admin component" HERE is sample using standAlone spring-bppt application using JDBC DB, and HERE you find a simple web application.

The REST API can be secured using credentials user/password and/or API Key. More information HERE

  1. All microservices access the REST API as clients and request feature store. You will need the dependency ff4j-webapi-jersey2x or ff4j-webapi-jersey1x that hold the client http> Then you can define the store using :

    FeatureStoreHttp storeHTT = new FeatureStoreHttp("http://localhost:9998/ff4j");

Warning : Please consider using cache to limit overhead introduce by accessing the REST API at each feature usage. More info on cache HERE

clunven
  • 1,360
  • 6
  • 13
  • Thanks @clunven for your response. I'll take a look at FeatureStoreHttp. It would help if you could point me to a sample that uses FeatureStoreHttp. Also, is there a specific format for the request/response that is expected by FeatureStoryHttp ? – Anoop Jul 28 '18 at 20:17
  • 1
    I took a look at FeatureStoreHttp.java. Turns out it adds `/store/features/` to the URI. I made the corresponding changes and things now work. Thank you @clunven for your inputs. – Anoop Jul 31 '18 at 15:21
  • What about Audit event's does this also work remotely using API? – Ondrej Bozek Nov 19 '18 at 18:29
  • On the CLIENT side you interact with REST to work with FF4j, Features and Properties (no AuditEvent in the FF4j bean). FF4j does not expose the AuditEvent as REST : you do not want the client to push event everytime. But on the SERVER side, the one exposing the API you define the AuditEventRepository, this is the server that will write data into the DB. – clunven Nov 22 '18 at 10:13