Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model-based Monitor API #158

Merged
merged 1 commit into from
Jun 16, 2021
Merged

Model-based Monitor API #158

merged 1 commit into from
Jun 16, 2021

Conversation

dave-tucker
Copy link
Collaborator

Specifying a custom Monitor is harder now we have models as it requires
the user to know the names of the Table and Fields they are interested
in. We already have this data in the model.

This commit changes the API to make it easier.

For example:

err = ovs.Monitor("play_with_ovs",
	ovs.NewTableMonitor(&OpenvSwitch{}),
	ovs.NewTableMonitor(&Bridge{}),
)

You can optionally provide pointers to the fields in a model to monitor
only those columns.

Signed-off-by: Dave Tucker dave@dtucker.co.uk

@coveralls
Copy link

coveralls commented Jun 14, 2021

Pull Request Test Coverage Report for Build 936990382

  • 43 of 64 (67.19%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 72.344%

Changes Missing Coverage Covered Lines Changed/Added Lines %
client/api.go 1 3 33.33%
mapper/info.go 1 4 25.0%
mapper/mapper.go 15 19 78.95%
client/client.go 26 38 68.42%
Totals Coverage Status
Change from base Build 928973283: -0.1%
Covered Lines: 2880
Relevant Lines: 3981

💛 - Coveralls

client/client.go Outdated Show resolved Hide resolved
client/client.go Outdated Show resolved Hide resolved
cache/cache_test.go Outdated Show resolved Hide resolved
@dave-tucker
Copy link
Collaborator Author

Thanks for the comments @halfcrazy. All addressed.

client/client.go Outdated Show resolved Hide resolved
mapper/mapper.go Outdated Show resolved Hide resolved
Specifying a custom Monitor is harder now we have models as it requires
the user to know the names of the Table and Fields they are interested
in. We already have this data in the model.

This commit changes the API to make it easier.

For example:

```
err = ovs.Monitor("play_with_ovs",
	ovs.NewTableMonitor(&OpenvSwitch{}),
	ovs.NewTableMonitor(&Bridge{}),
)
```

You can optionally provide pointers to the fields in a model to monitor
only those columns.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Copy link
Collaborator

@amorenoz amorenoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits. Otherwise LGTM

columns = append(columns, column)
}
} else {
for c := range info.table.Columns {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think empty columns stand for "all" columns

@@ -254,18 +257,11 @@ func (ovs OvsdbClient) Transact(operation ...ovsdb.Operation) ([]ovsdb.Operation

// MonitorAll is a convenience method to monitor every table/column
func (ovs OvsdbClient) MonitorAll(jsonContext interface{}) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if MonitorAll could just be replaced by Monitor with no options...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could. And I think we can address that in a follow up that deprecates MonitorAll entirely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dave-tucker dave-tucker merged commit 178a18c into ovn-org:main Jun 16, 2021
@dave-tucker dave-tucker added this to the 0.5.0 milestone Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants