![]() ![]() Given that Event Hubs Data Generator makes use of a library called JSON-Faker-Schema – it would be wise to refer to the documentation provided on their Github when you’re getting started. JSON-Faker-Schema adheres to the JSON Schema, which is a standard for a valid JSON file. The data generated will be based on the schema provided by the user. JSON-Faker-Schema can generate realistic fake data in JSON format for many areas, including people, address, finance, and company etc. JSON-Faker-SchemaĮvent Hub Data Generator (EHDG) is heavily based on the work of JSON-Schema-Faker’s JavaScript library. Fake data serves to exist where real data is normally present, acting as a placeholder for testing purposes in a non-production environment. This is where fake data, otherwise known as test or dummy data comes in. Not every developer has the time to generate a tool to populate their databases or ingestion services. Highly scalable and reliable, it can receive and process millions of events per second with low latency.Įvent Hubs can be used for a number of different scenarios, such as: Event HubsĪzure Event Hubs, a Platform-as-a-Service offering, is a big data streaming platform and event ingestion service. Event Hub Data Generator (EHDG) is here to make simplify this process and allow the developer to work on the later parts of the pipeline sooner. Even if they had access to real data they could stream, real data is often messy – requiring endless cleaning. ![]() Setting up this stream of hot data, particularly data that is useful for your use case, can be a tedious and lengthy process. For instance, if someone is trying to demonstrate streaming data sets in PowerBI, they likely need to set up a stream analytics job, and in order for them to set up a stream analytics job, they need data in particular hot data. The purpose is to remove the pain of initial set up that is faced by many developers. For simplicity, we added a schema that only contains a name property, and provided an array of examples.Īfter that, we just generate the object like we did in the previous section.Event Hub Data Generator (EHDG) is a tool which generates realistic fake data based on a provided schema and sends it to Azure Event Hubs. You can check below a simple example where we are making use of this option (notice that we are setting it to true at the beginning of the code). When set to true, it will return a random value from the examples array, if it exists. The one we are interested on is called useExamplesValue. You can check the full list of options here. Nonetheless, there is a method called option on the jsf object that we can call to set some configurations. In this particular application of generating testing data, the examples array can also be used by the package to retrieve values. Note that these examples are not used for the actual schema validation but may be helpful to document it. The examples keyword allows to specify an array of examples that validate against the schema. We are not going to cover those more advanced use cases on this tutorial but rather a simpler alternative: the examples keyword of the JSON schema. Providing custom data examplesĪs mentioned before, we can use additional data generators to generate more specific data for some fields, if needed. Take in consideration that running the previous code multiple times will give different results, since the data is randomly generated.įigure 1 – Output of the program, showing the generated object with fake data. For example, Faker.js allows to generate random people names, which could have been used in this use case. This allows to generate more realistic data if needed. However, additional data generators such as Faker.js or Chance.js can be added, as can be seen here. Naturally, since the type of the property in the JSON schema was a string, there was no additional information that allowed to generate more realistic data. Note that, for the name, we obtained a random string that is not a person name. As can be seen, we got an object that conforms with our schema. You should get an output similar to figure 1. I’ll be using Visual Studio Code with the Code Runner extension. To test the previous code, simply run it in a tool of your choice. Const jsf = require('json-schema-faker') Ĭonst schemaAsObject = JSON.parse(schema) Ĭonst obj = jsf.generate(schemaAsObject)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |