refactor: interfaces and data types into the model package (#642)
## 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
This commit is contained in:
parent
69aca619ea
commit
273b70bacc
275 changed files with 1281 additions and 1375 deletions
|
|
@ -1,32 +0,0 @@
|
|||
package sessionresolver
|
||||
|
||||
// KVStore is a generic key-value store. We use it to store
|
||||
// on disk persistent state used by this package.
|
||||
type KVStore interface {
|
||||
// Get gets the value for the given key.
|
||||
Get(key string) ([]byte, error)
|
||||
|
||||
// Set sets the value of the given key.
|
||||
Set(key string, value []byte) error
|
||||
}
|
||||
|
||||
// Logger defines the common logger interface.
|
||||
type Logger interface {
|
||||
// Debug emits a debug message.
|
||||
Debug(msg string)
|
||||
|
||||
// Debugf formats and emits a debug message.
|
||||
Debugf(format string, v ...interface{})
|
||||
|
||||
// Info emits an informational message.
|
||||
Info(msg string)
|
||||
|
||||
// Infof format and emits an informational message.
|
||||
Infof(format string, v ...interface{})
|
||||
|
||||
// Warn emits a warning message.
|
||||
Warn(msg string)
|
||||
|
||||
// Warnf formats and emits a warning message.
|
||||
Warnf(format string, v ...interface{})
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// resolvemaker contains rules for making a resolver.
|
||||
|
|
@ -67,7 +68,7 @@ func (r *Resolver) byteCounter() *bytecounter.Counter {
|
|||
}
|
||||
|
||||
// logger returns the configured logger or a default
|
||||
func (r *Resolver) logger() Logger {
|
||||
func (r *Resolver) logger() model.Logger {
|
||||
if r.Logger != nil {
|
||||
return r.Logger
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/bytecounter"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/multierror"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
|
@ -63,11 +64,11 @@ type Resolver struct {
|
|||
// KVStore is the MANDATORY key-value store where you
|
||||
// want us to write statistics about which resolver is
|
||||
// working better in your network.
|
||||
KVStore KVStore
|
||||
KVStore model.KeyValueStore
|
||||
|
||||
// Logger is the optional logger you want us to use
|
||||
// to emit log messages.
|
||||
Logger Logger
|
||||
Logger model.Logger
|
||||
|
||||
// ProxyURL is the optional URL of the socks5 proxy
|
||||
// we should be using. If not set, then we WON'T use
|
||||
|
|
|
|||
Loading…
Reference in a new issue