273b70bacc
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885 - [x] related ooni/spec pull request: N/A Location of the issue tracker: https://github.com/ooni/probe ## Description This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package. The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity. An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other. This is what I want to move in `internal/model`: - [x] most important interfaces from `internal/netxlite` - [x] everything that was previously part of `internal/engine/model` - [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
// Package ooapi contains a client for the OONI API. We
|
|
// automatically generate the code in this package from the
|
|
// apimodel and internal/generator packages.
|
|
//
|
|
// Note
|
|
//
|
|
// This package is currrently unused. We plan on replacing
|
|
// existing code to speak with the OONI API with it.
|
|
//
|
|
// Usage
|
|
//
|
|
// You need to create a Client. Make sure you set all
|
|
// the mandatory fields. You will then have a function
|
|
// for every supported OONI API. This function will
|
|
// take in input a context and a request. You need to
|
|
// fill the request, of course. The return value is
|
|
// either a response or an error.
|
|
//
|
|
// If an API requires login, we will automatically
|
|
// perform the login. If an API uses caching, we will
|
|
// automatically use the cache.
|
|
//
|
|
// Design
|
|
//
|
|
// Most of the code in this package is auto-generated from the
|
|
// data model in ./apimodel and the definition of APIs provided
|
|
// by ./internal/generator/spec.go.
|
|
//
|
|
// We keep the generated files up-to-date by running
|
|
//
|
|
// go generate ./...
|
|
//
|
|
// We have tests that ensure that the definition of the API
|
|
// used here is reasonably close to the server's one.
|
|
//
|
|
// Testing
|
|
//
|
|
// The following command
|
|
//
|
|
// go test ./...
|
|
//
|
|
// will, among other things, ensure that the our API spec
|
|
// is consistent with the server's one. Running
|
|
//
|
|
// go test -short ./...
|
|
//
|
|
// will exclude most (slow) integration tests.
|
|
//
|
|
// Architecture
|
|
//
|
|
// The ./apimodel sub-package contains the definition of request
|
|
// and response messages. We rely on tagging to specify how
|
|
// we should encode and decode messages.
|
|
//
|
|
// The ./internal/generator sub-package contains code to generate most
|
|
// code in this package. In particular, the spec.go file is
|
|
// the specification of the APIs.
|
|
package ooapi
|