|
| 1 | +# Settings Configuration |
| 2 | + |
| 3 | +The `settings.py` file is the central configuration file for registering your interoperability components. It defines classes, productions, schemas, and remote connection settings. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +Create a `settings.py` file in your project root: |
| 8 | + |
| 9 | +```python |
| 10 | +import bo |
| 11 | + |
| 12 | +CLASSES = { |
| 13 | + "Python.MyBusinessOperation": bo.MyBusinessOperation |
| 14 | +} |
| 15 | +``` |
| 16 | + |
| 17 | +Register your components: |
| 18 | +```bash |
| 19 | +iop --migrate /path/to/your/project/settings.py |
| 20 | +``` |
| 21 | + |
| 22 | +## Configuration Sections |
| 23 | + |
| 24 | +The `settings.py` file supports four main sections: |
| 25 | + |
| 26 | +| Section | Purpose | Required | |
| 27 | +|---------|---------|----------| |
| 28 | +| `CLASSES` | Define interoperability components | ✅ | |
| 29 | +| `PRODUCTIONS` | Configure production workflows | ❌ | |
| 30 | +| `SCHEMAS` | Register message schemas for DTL | ❌ | |
| 31 | +| `REMOTE_SETTINGS` | Configure remote IRIS connections | ❌ | |
| 32 | + |
| 33 | +## CLASSES Section |
| 34 | + |
| 35 | +Register your interoperability components (BusinessOperations, BusinessProcesses, BusinessServices). |
| 36 | + |
| 37 | +### Basic Usage |
| 38 | + |
| 39 | +```python |
| 40 | +import bo |
| 41 | +from bs import RedditService |
| 42 | + |
| 43 | +CLASSES = { |
| 44 | + 'Python.RedditService': RedditService, |
| 45 | + 'Python.FileOperation': bo.FileOperation, |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +## PRODUCTIONS Section |
| 50 | + |
| 51 | +Define complete production configurations with multiple components. |
| 52 | + |
| 53 | +### Minimal Production |
| 54 | + |
| 55 | +```python |
| 56 | +PRODUCTIONS = [ |
| 57 | + { |
| 58 | + 'MyApp.Production': { |
| 59 | + "@Name": "MyApp.Production", |
| 60 | + "Item": [ |
| 61 | + { |
| 62 | + "@Name": "FileProcessor", |
| 63 | + "@ClassName": "Python.FileOperation", |
| 64 | + }, |
| 65 | + { |
| 66 | + "@Name": "EmailSender", |
| 67 | + "@ClassName": "Python.EmailOperation" |
| 68 | + } |
| 69 | + ] |
| 70 | + } |
| 71 | + } |
| 72 | +] |
| 73 | +``` |
| 74 | + |
| 75 | +### Full Production Configuration |
| 76 | + |
| 77 | +```python |
| 78 | +import os |
| 79 | +from bo import FileOperation |
| 80 | + |
| 81 | +PRODUCTIONS = [ |
| 82 | + { |
| 83 | + 'Demo.Production': { |
| 84 | + "@Name": "Demo.Production", |
| 85 | + "@TestingEnabled": "true", |
| 86 | + "@LogGeneralTraceEvents": "false", |
| 87 | + "Description": "Sample production for demonstration", |
| 88 | + "ActorPoolSize": "2", |
| 89 | + "Item": [ |
| 90 | + { |
| 91 | + "@Name": "FileProcessor", |
| 92 | + "@ClassName": "Python.FileOperation", |
| 93 | + "@PoolSize": "1", |
| 94 | + "@Enabled": "true", |
| 95 | + "@LogTraceEvents": "true", |
| 96 | + "Setting": { |
| 97 | + "@Target": "Host", |
| 98 | + "@Name": "%settings", |
| 99 | + "#text": f"path={os.environ.get('DATA_PATH', '/tmp')}" |
| 100 | + } |
| 101 | + } |
| 102 | + ] |
| 103 | + } |
| 104 | + } |
| 105 | +] |
| 106 | +``` |
| 107 | + |
| 108 | +**Production Attributes:** |
| 109 | +- `@Name`: Production display name |
| 110 | +- `@TestingEnabled`: Enable testing mode (`"true"`/`"false"`) |
| 111 | +- `@LogGeneralTraceEvents`: Enable general logging |
| 112 | +- `ActorPoolSize`: Number of concurrent actors |
| 113 | + |
| 114 | +**Item Attributes:** |
| 115 | +- `@Name`: Component instance name |
| 116 | +- `@ClassName`: Class reference (from CLASSES or direct class) |
| 117 | +- `@PoolSize`: Component pool size |
| 118 | +- `@Enabled`: Enable/disable component |
| 119 | +- `@LogTraceEvents`: Enable component-specific logging |
| 120 | +- `Setting`: Component configuration settings |
| 121 | + |
| 122 | +## SCHEMAS Section |
| 123 | + |
| 124 | +Register message schemas for Data Transformation Language (DTL) operations. |
| 125 | + |
| 126 | +```python |
| 127 | +from msg import RedditPost, UserProfile |
| 128 | + |
| 129 | +SCHEMAS = [RedditPost, UserProfile] |
| 130 | +``` |
| 131 | + |
| 132 | +## REMOTE_SETTINGS Section |
| 133 | + |
| 134 | +Configure connections to remote IRIS instances for component migration. |
| 135 | + |
| 136 | +```python |
| 137 | +REMOTE_SETTINGS = { |
| 138 | + "url": "http://localhost:8080", # Required |
| 139 | + "username": "SuperUser", # Optional |
| 140 | + "password": "SYS", # Optional |
| 141 | + "namespace": "IRISAPP", # Optional (default: "USER") |
| 142 | + "remote_folder": "", # Optional (default: folder of the routine database) |
| 143 | + "package": "python" # Optional (default: "python") |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +**Configuration Options:** |
| 148 | +- `url`: Remote IRIS instance URL (required) |
| 149 | +- `username`: Authentication username |
| 150 | +- `password`: Authentication password |
| 151 | +- `namespace`: Target namespace for components |
| 152 | +- `remote_folder`: Remote storage folder |
| 153 | +- `package`: Package name for components |
| 154 | + |
| 155 | +## Complete Example |
| 156 | + |
| 157 | +```python |
| 158 | +import os |
| 159 | +import bp |
| 160 | +from bo import FileOperation, EmailOperation |
| 161 | +from bs import RedditService |
| 162 | +from msg import RedditPost |
| 163 | + |
| 164 | +# Remote connection settings |
| 165 | +REMOTE_SETTINGS = { |
| 166 | + "url": "http://iris-server:8080", |
| 167 | + "username": "SuperUser", |
| 168 | + "password": "SYS", |
| 169 | + "namespace": "IRISAPP" |
| 170 | +} |
| 171 | + |
| 172 | +# Component registration |
| 173 | +CLASSES = { |
| 174 | + 'Python.RedditService': RedditService, |
| 175 | + 'Python.FileOperation': FileOperation, |
| 176 | + 'Python.EmailOperation': EmailOperation, |
| 177 | + 'Python.FilterRule': bp.FilterPostRoutingRule, |
| 178 | +} |
| 179 | + |
| 180 | +# Message schemas |
| 181 | +SCHEMAS = [RedditPost] |
| 182 | + |
| 183 | +# Production configuration |
| 184 | +PRODUCTIONS = [ |
| 185 | + { |
| 186 | + 'Reddit.Production': { |
| 187 | + "@Name": "Reddit Processing Pipeline", |
| 188 | + "@TestingEnabled": "true", |
| 189 | + "ActorPoolSize": "3", |
| 190 | + "Item": [ |
| 191 | + { |
| 192 | + "@Name": "RedditFeed", |
| 193 | + "@ClassName": "Python.RedditService", |
| 194 | + "@Enabled": "true", |
| 195 | + "Setting": { |
| 196 | + "@Target": "Host", |
| 197 | + "@Name": "%settings", |
| 198 | + "#text": f"limit={os.environ.get('REDDIT_LIMIT', '10')}" |
| 199 | + } |
| 200 | + }, |
| 201 | + { |
| 202 | + "@Name": "PostFilter", |
| 203 | + "@ClassName": "Python.FilterRule", |
| 204 | + "@Enabled": "true" |
| 205 | + }, |
| 206 | + { |
| 207 | + "@Name": "FileExporter", |
| 208 | + "@ClassName": "Python.FileOperation", |
| 209 | + "@Enabled": "true" |
| 210 | + } |
| 211 | + ] |
| 212 | + } |
| 213 | + } |
| 214 | +] |
| 215 | +``` |
| 216 | + |
| 217 | +## Best Practices |
| 218 | + |
| 219 | +1. **Use descriptive names** for components and productions |
| 220 | +2. **Import modules at the top** of your settings file |
| 221 | +3. **Use environment variables** for sensitive data and paths |
| 222 | +4. **Group related components** in the same production |
| 223 | +5. **Enable logging** during development and testing |
| 224 | +6. **Document complex productions** with clear descriptions |
0 commit comments