|
1 | 1 | # datagen |
| 2 | + |
| 3 | +Datagen is a CLI utility to generate JSON data using fake values. |
| 4 | +It generates data to a file, or to Kafka. |
| 5 | + |
| 6 | +## Usage |
| 7 | + |
| 8 | +### Examples |
| 9 | +**Generate data to a file** |
| 10 | +``` |
| 11 | +./datagen create --filesystem --from ./templates/myTemplate.json |
| 12 | +``` |
| 13 | + |
| 14 | +It generates data using `myTemplate.json` to a file in `./data/data.txt`. |
| 15 | + |
| 16 | +**Generate data to Kafka** |
| 17 | +``` |
| 18 | +./datagen create --kafka --topic myTopic --from ./templates/myTemplate.json |
| 19 | +``` |
| 20 | + |
| 21 | +It generates data using `myTemplate.json` to a kafka topic named `myTopic`. The data will continue to be generated until datagen is stopped. |
| 22 | + |
| 23 | +## Templates |
| 24 | +Datagen relies on valid JSON template documents to generate the data. The templates allow for the creation of fake data. Fake data can be specified using the syntax `fake:{<fake specifier>}` where `<fake specifier>` must be replaced with one of: |
| 25 | + |
| 26 | +**Numbers** |
| 27 | +``` |
| 28 | +number:<min>,<max> |
| 29 | +int8 |
| 30 | +int16 |
| 31 | +int32 |
| 32 | +int64 |
| 33 | +uint8 |
| 34 | +uint16 |
| 35 | +uint32 |
| 36 | +uint64 |
| 37 | +float32 |
| 38 | +float32range:<min>,<max> |
| 39 | +float64 |
| 40 | +float64range:<min>,<max> |
| 41 | +``` |
| 42 | +**Strings** |
| 43 | +``` |
| 44 | +digit |
| 45 | +letter |
| 46 | +lexify:<string> |
| 47 | +numerify:<string> |
| 48 | +``` |
| 49 | +**Person** |
| 50 | +``` |
| 51 | +person |
| 52 | +name |
| 53 | +nameprefix |
| 54 | +namesuffix |
| 55 | +firstname |
| 56 | +lastname |
| 57 | +gender |
| 58 | +ssn |
| 59 | +contact |
| 60 | +email |
| 61 | +phone |
| 62 | +phoneformatted |
| 63 | +``` |
| 64 | + |
| 65 | +...TODO Add more here |
| 66 | + |
| 67 | +### Template Example |
| 68 | + |
| 69 | +``` |
| 70 | +{ |
| 71 | + "id": "fake:{number:1,11}", |
| 72 | + "name": "fake:{uint64}", |
| 73 | + "department": "IT", |
| 74 | + "designation": "Product Manager", |
| 75 | + "username": "fake:{username}", |
| 76 | + "password": "fake:{password}", |
| 77 | + "address1": "fake:{address}", |
| 78 | + "latitude": "fake:{latitude}", |
| 79 | + "longitude": "fake:{longitude}", |
| 80 | + "latitudeInRange": "fake:{latituderange:23.1,56.7}", |
| 81 | + "address": { |
| 82 | + "city": "Mumbai", |
| 83 | + "state": "Maharashtra", |
| 84 | + "country": "India" |
| 85 | + } |
| 86 | +} |
| 87 | +``` |
| 88 | + |
| 89 | +The above template would produce JSON documents like the following: |
| 90 | + |
| 91 | +``` |
| 92 | +{ |
| 93 | + "address": { |
| 94 | + "city": "Mumbai", |
| 95 | + "country": "India", |
| 96 | + "state": "Maharashtra" |
| 97 | + }, |
| 98 | + "address1": { |
| 99 | + "address": "New Mexico Stehrtown Valleyschester743号 ", |
| 100 | + "street": "Valleyschester743号", |
| 101 | + "city": "Stehrtown", |
| 102 | + "state": "New Mexico", |
| 103 | + "zip": "36339", |
| 104 | + "country": "New Caledonia", |
| 105 | + "latitude": -49.659845, |
| 106 | + "longitude": 18.110164 |
| 107 | + }, |
| 108 | + "department": "IT", |
| 109 | + "designation": "Product Manager", |
| 110 | + "id": 5, |
| 111 | + "latitude": -1.947745, |
| 112 | + "latitudeInRange": 29.420478, |
| 113 | + "longitude": -27.482948, |
| 114 | + "name": 5427729115751982900, |
| 115 | + "password": "vGdku\u0026$ZGi8#", |
| 116 | + "username": "Kiehn4009" |
| 117 | +} |
| 118 | +``` |
0 commit comments