Skip to content

Commit

Permalink
Add explanation for mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
waseem-h committed Feb 27, 2018
1 parent 0810579 commit 8bf447a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,18 @@ func (mp *MonitorServiceProxy) OfType(mType string) MonitorServiceProxy {
}
```

Note that the name you specify here for the case will be the key for your new monitor which you can add it in ConfigMap.
Note that the name you specify here for the case will be the key for your new monitor which you can add it in ConfigMap.

Also in case of handling custom api objects for the monitor api, you can create mappers that map from the api objects to the generic `Monitor` objects. The way you have to create these is to create a file named `monitorname-mappers.go` and add mapping functions in that file. An example of a mapping function is found below:

```go
func UptimeMonitorMonitorToBaseMonitorMapper(uptimeMonitor UptimeMonitorMonitor) *Monitor {
var m Monitor
m.name = uptimeMonitor.FriendlyName
m.url = uptimeMonitor.URL
m.id = strconv.Itoa(uptimeMonitor.ID)
return &m
}
```

0 comments on commit 8bf447a

Please sign in to comment.