Skip to content

Commit

Permalink
tweak intro docs (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Dec 13, 2017
1 parent c86d616 commit 1efbe95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Prerequisite: NPM and Node.js
Stop given collector
stop --name --refocusProxy

Show status of collector
Show status of collector
status --name --refocusProxy

Deregister given collector
Deregister given collector
deregister --name --refocusProxy

Reregister given collector. refocusProxy is an optional argument
Reregister given collector. refocusProxy is an optional argument
reregister --collectorName --refocusUrl --accessToken --refocusProxy

Display help for [cmd]
Expand All @@ -53,4 +53,6 @@ Prerequisite: NPM and Node.js

-----

[Introduction to Sample Generators](docs/pages/collectorintro.md)
[Introduction to Collectors](docs/pages/collectorintro.md)
[Introduction to Sample Generators](docs/pages/samplegenintro.md)

12 changes: 6 additions & 6 deletions docs/pages/samplegenintro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ We like to think of Sample Generators as the *brains* within a Collector. They p

# What's in a Sample Generator?

Continuing our theme of modularity, Sample Generators leverage Generator Templates which define the transform code (Javascript code) used to create Samples. Generator Templates will often, but not always, be written by a third party. This is because we want to make it easy for non-technical users to get data into Refocus so we let them leverage code written by technical users. Generator Templates are meant to be reusable. Once written, many users will use the same Template to push data into Refocus.
Continuing our theme of modularity, Sample Generators leverage Generator Templates which define the transform code (Javascript code) used to create Samples. Generator Templates will often, but not always, be written by a third party. This is because we want to make it easy for non-technical users to get data into Refocus so we let them leverage code written by technical users. Generator Templates are meant to be reusable. Once written, many users will use the same Template to push data into Refocus.

![Collector using SG Diagram](../assets/SGDiagram.jpeg)
![Collector using SG Diagram](../assets/SGDiagram.jpg)

This diagram illustrates the major components of a Sample Generator. You can see that they have a context where variable values are set and they also use Generator Templates.
This diagram illustrates the major components of a Sample Generator. You can see that they have a context where variable values are set and they also use Generator Templates.

A Sample Generator specifies the particular Generator Template it wants to use. It then provides values to context variables that the Generator Template uses to execute its code.

In this simple example, the Generator Template returns an array of greetings that the user provides. The variables are user configurable and depend on the values set in the Sample Generator.
In this simple example, the Generator Template returns an array of greetings that the user provides. The variables are user configurable and depend on the values set in the Sample Generator.

The result here is an array of greetings but in reality, transform functions will return an array of Samples which will be sent to your Refocus instance.
The result here is an array of greetings but in reality, transform functions will return an array of Samples which will be sent to your Refocus instance.

# Tell me more about Generator Templates

A Generator Template provides a Sample Generator with some Javascript code which transforms the response from your data source into Samples. Generator Templates are created with a specific data source in mind.

For example, I could write a Generator Template that leverages the API of my favorite Bitcoin exchange, BitX! It'll expect input data in the format used by that exchange as well as a mapping from currency value to Refocus Samples status. Then it will convert the return values into Samples for Refocus.
For example, I could write a Generator Template that leverages the API of my favorite Bitcoin exchange, BitX! It'll expect input data in the format used by that exchange as well as a mapping from currency value to Refocus Samples status. Then it will convert the return values into Samples for Refocus.

Then let's say you want to track how your Bitcoin portfolio is performing in real time. You may want Refocus to show 'Critical' if Bitcoin prices drop below $3000 and 'Ok' otherwise. You would create a Sample Generator that references my Generator Template and provides a mapping from USD to Status as well as the URL for the BitX instance you want to query. Submit that to Refocus and you're done!

Expand Down

0 comments on commit 1efbe95

Please sign in to comment.