Last updated:
0 purchases
pip services4 config
Config components definitions for Dart #
This module is a part of the Pip.Services polyglot microservices toolkit.
The Config module contains configuration component definitions that can be used to build applications and services.
The module contains the following packages:
Auth - authentication credential stores
Config - configuration readers and managers, whose main task is to deliver configuration parameters to the application from wherever they are being stored
Connect - connection discovery and configuration services
Quick links:
Logging
Configuration
API Reference
Change Log
Get Help
Contribute
Examples
Warning!
Config package now not work with condition {{#if var}} something {{/}} in config files.
Use Mustache syntax, for example {{#var}} something {{/var}}
Use #
Add this to your package's pubspec.yaml file:
dependencies:
pip_services4_config: version
copied to clipboard
Now you can install package from the command line:
pub get
copied to clipboard
Example how to get connection parameters and credentials using resolvers.
The resolvers support "discovery_key" and "store_key" configuration parameters
to retrieve configuration from discovery services and credential stores respectively.
import 'package:pip_services4_commons/src/config/ConfigParams.dart';
import 'package:pip_services4_commons/src/config/IConfigurable.dart';
import 'package:pip_services4_commons/src/refer/IReferences.dart';
import 'package:pip_services4_commons/src/refer/IReferenceable.dart';
import 'package:pip_services4_commons/src/run/IOpenable.dart';
import 'package:pip_services4_config/src/connect/ConnectionParams.dart';
import 'package:pip_services4_config/src/connect/ConnectionResolver.dart';
import 'package:pip_services4_config/src/auth/CredentialParams.dart';
import 'package:pip_services4_config/src/auth/CredentialResolver.dart';
class MyComponent implements IConfigurable, IReferenceable, IOpenable {
final _connectionResolver = ConnectionResolver();
final _credentialResolver = CredentialResolver();
bool _opened = false;
@override
void configure(ConfigParams config) {
_connectionResolver.configure(config);
_credentialResolver.configure(config);
}
@override
void setReferences(IReferences refs) {
_connectionResolver.setReferences(refs);
_credentialResolver.setReferences(refs);
}
// ...
@override
Future open(IContext? context) async {
ConnectionParams? connection =
await _connectionResolver.resolve(context);
CredentialParams? credential =
await _credentialResolver.lookup(context);
if (connection != null && credential != null) {
String? host = connection.getHost();
int? port = connection.getPort();
String? user = credential.getUsername();
String? pass = credential.getPassword();
// ...
_opened = true;
}
}
}
// Using the component
var myComponent = new MyComponent();
myComponent.configure(ConfigParams.fromTuples(
'connection.host', 'localhost',
'connection.port', 1234,
'credential.username', 'anonymous',
'credential.password', 'pass123'
));
await myComponent.open(null);
copied to clipboard
Develop #
For development you shall install the following prerequisites:
Dart SDK 3
Visual Studio Code or another IDE of your choice
Docker
Install dependencies:
pub get
copied to clipboard
Run automated tests:
pub run test
copied to clipboard
Generate API documentation:
./docgen.ps1
copied to clipboard
Before committing changes run dockerized build and test as:
./build.ps1
./test.ps1
./clear.ps1
copied to clipboard
Contacts #
The library is created and maintained by Sergey Seroukhov and Levichev Dmitry.
The documentation is written by Egor Nuzhnykh, Alexey Dvoykin, Mark Makarychev, Levichev Dmitry.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.