Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code formatting in README #95

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 56 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ What makes Baigan a rockstar configuration framework ?
### To build the project run:

```bash
mvn clean install -Pintegration-test
./mvnw clean install -Pintegration-test
```

### Integrating Baigan config
Expand All @@ -36,8 +36,8 @@ Baigan config is a spring project. The larger part of integration involves confi

import org.zalando.baigan.BaiganSpringContext;

@ComponentScan(basePackageClasses = {BaiganSpringContext.class })
@ConfigurationServiceScan(basePackages = {"com.foo.configurations" })
@ComponentScan(basePackageClasses = { BaiganSpringContext.class })
@ConfigurationServiceScan(basePackages = { "com.foo.configurations" })
public class Application {
}
```
Expand All @@ -48,19 +48,19 @@ And the _@ConfigurationServiceScan_ annotation hints the Baigan registrar to loo
#### Annotate your configuration interfaces with _@BaiganConfig_

```Java
@BaiganConfig
public interface ExpressFeature {
@BaiganConfig
public interface ExpressFeature {

Boolean enabled();
Boolean enabled();

String serviceUrl();
String serviceUrl();

SomeStructuredConfigClass complexConfiguration();

List<String> configList();
SomeStructuredConfigClass complexConfiguration();

Map<UUID, List<SomeConfigObject>> nestedGenericConfiguration();
}
List<String> configList();

Map<UUID, List<SomeConfigObject>> nestedGenericConfiguration();
}
```

The individual methods may have arbitrary classes as return types, in particular complex structured types are supported, including Generics.
Expand All @@ -70,20 +70,20 @@ The individual methods may have arbitrary classes as return types, in particular
The above example code enables the application to inject _ExpressFeature_ spring bean into any other Spring bean:

```Java
@Component
public class ExpressServiceImpl implements ExpressService{

@Inject
private ExpressFeature expressFeature;

@Override
public void sendShipment(final Shipment shipment){
if (expressFeature.enabled()){
final String serviceUrl = expressFeature.serviceUrl();
// Use the configuration
}
}
}
@Component
public class ExpressServiceImpl implements ExpressService {

@Inject
private ExpressFeature expressFeature;

@Override
public void sendShipment(final Shipment shipment) {
if (expressFeature.enabled()) {
final String serviceUrl = expressFeature.serviceUrl();
// Use the configuration
}
}
}
```

#### Provide a configuration repository
Expand All @@ -93,15 +93,16 @@ This is done using the Spring Bean of type `RepositoryFactory`, which allows cre
types. The following example shows how to configure a filesystem based repository.

```Java
@Configuration
public class ApplicationConfiguration {

@Bean
public ConfigurationRepository configurationRepository(RepositoryFactory factory){
return factory.fileSystemConfigurationRepository()
.fileName("configs.json");
}
}
@Configuration
public class ApplicationConfiguration {

@Bean
public ConfigurationRepository configurationRepository(RepositoryFactory factory) {
return factory.fileSystemConfigurationRepository()
.fileName("configs.json")
.build();
}
}
```

Check the documentation of the builders for details on how to configure the repositories. In particular, all
Expand Down Expand Up @@ -139,13 +140,13 @@ A configuration object should conform to the following JSON Schema:
"description": "List of conditions to check",
"type": "array",
"items": {
"type": "object",
"properties": {
"type": "object",
"properties": {
"value": {
"description": "Configuration value if this condition evaluates to true.",
"type": {}
},
"conditionType": {
"conditionType": {
"description": "Type of condition to evaluate. This can be custom defined, with custom defined properties.",
"type": "object"
}
Expand All @@ -162,21 +163,23 @@ A configuration object should conform to the following JSON Schema:
This sample JSON defines a configuration for the key `express.feature.enabled` with the value _true_ when the _country_code_ is 3, and a default value of _false_.

```json
{
"alias": "express.feature.enabled",
"description": "Feature toggle",
"defaultValue": false,
"conditions": [
{
"value": true,
"conditionType": {
"onValue": "3",
"type": "Equals"
},
"paramName": "country_code"
}
]
}
[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this listing was always meant as just as an excerpt of a whole file, hence omitting the brackets. I strongly agree with the change though, it has always been confusing 😄

{
"alias": "express.feature.enabled",
"description": "Feature toggle",
"defaultValue": false,
"conditions": [
{
"value": true,
"conditionType": {
"onValue": "3",
"type": "Equals"
},
"paramName": "country_code"
}
]
}
]
```

#### Pushing configuration to repositories
Expand Down