Documentation ¶
Overview ¶
Package model defines functions for generating random sets of model databases, devices, and users that will be simulated in a syncbase longevity test.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( LaptopSpec = DeviceSpec{ MaxDatabases: 10, ConnectivitySpecs: []ConnectivitySpec{"online", "offline"}, } PhoneSpec = DeviceSpec{ MaxDatabases: 5, ConnectivitySpecs: []ConnectivitySpec{"online", "offline"}, } CloudSpec = DeviceSpec{ MaxDatabases: 100, ConnectivitySpecs: []ConnectivitySpec{"online"}, } )
Some common DeviceSpecs. It would be nice if these were consts, but go won't allow that.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { // Name of the collection. Name string // Blessing of the collection. Blessing string // Permissions of the collection. Permissions Permissions }
Collection represents a syncbase collection. TODO(nlacasse): Put syncgroups in here? It's a bit tricky because they need to have a host device name in their name, and the spec depends on the mounttable.
func (*Collection) Id ¶
func (c *Collection) Id() wire.Id
func (*Collection) String ¶
func (c *Collection) String() string
type CollectionSet ¶
type CollectionSet []Collection
func (CollectionSet) String ¶
func (cols CollectionSet) String() string
type ConnectivitySpec ¶
type ConnectivitySpec string
ConnectivitySpec specifies the network connectivity of the device.
const ( Online ConnectivitySpec = "online" Offline ConnectivitySpec = "offline" )
type Database ¶
type Database struct { // Name of the database. Name string // Blessing of the database. Blessing string // Collections. Collections CollectionSet // Syncgroups. Syncgroups SyncgroupSet // Permissions. Permissions Permissions }
Database represents a syncbase database. Each database corresponds to a single app.
type DatabaseSet ¶
type DatabaseSet []*Database
DatabaseSet represents a set of Databases. TODO(nlacasse): Consider using a map here if uniqueness becomes an issue.
func GenerateDatabaseSet ¶
func GenerateDatabaseSet(n int) DatabaseSet
GenerateDatabaseSet generates a DatabaseSet with n databases. TODO(nlacasse): Generate collections and syncgroups. TODO(nlacasse): Generate clients.
func (DatabaseSet) RandomSubset ¶
func (dbs DatabaseSet) RandomSubset(min, max int) DatabaseSet
RandomSubset returns a random subset of the DatabaseSet with at least min and at most max databases.
func (DatabaseSet) String ¶
func (dbs DatabaseSet) String() string
type Device ¶
type Device struct { // Name of the device. Name string // Databases inluded on the device. Databases DatabaseSet // The device's spec. Spec DeviceSpec // Current connectivity spec for the device. This value must be included // in Spec.ConnectivitySpecs. CurrentConnectivity ConnectivitySpec // Associated clients that will operate on this syncbase instance. Clients // must be registered with control.RegisterClient. Clients []string }
Device represents a device.
type DeviceSet ¶
type DeviceSet []*Device
DeviceSet is a set of devices. TODO(nlacasse): Consider using a map here if uniqueness becomes an issue.
func GenerateDeviceSet ¶
func GenerateDeviceSet(n int, databases DatabaseSet, specs []DeviceSpec) DeviceSet
GenerateDeviceSet generates a device set of size n. The device spec for each device is chosen randomly from specs, and each device is given a non-empty set of databases taken from databases argument, obeying the maxium for the device spec.
type DeviceSpec ¶
type DeviceSpec struct { // Maximum number of databases allowed on the device. MaxDatabases int // Types of connectivity allowed for the database. ConnectivitySpecs []ConnectivitySpec }
DeviceSpec specifies the possible types of devices.
type Permissions ¶
Permissions maps tags to Users who are included on that tag. TODO(nlacasse): Consider allowing blacklisted users with "NotIn" lists.
func (Permissions) FilterTags ¶
func (perms Permissions) FilterTags(allowTags ...access.Tag) Permissions
func (Permissions) ToWire ¶
func (perms Permissions) ToWire(rootBlessing string) access.Permissions
type Syncgroup ¶
type Syncgroup struct { HostDevice *Device Name string Blessing string Description string Collections []Collection Permissions Permissions IsPrivate bool // Devices which will attempt to create the syncgroup. CreatorDevices DeviceSet // Devices which will attempt to join the syncgroup. JoinerDevices DeviceSet }
Syncgroup represents a syncgroup.
type SyncgroupSet ¶
type SyncgroupSet []Syncgroup
func (SyncgroupSet) String ¶
func (sgs SyncgroupSet) String() string
type Topology ¶
Topology is an adjacency matrix specifying the connection type between devices. TODO(nlacasse): For now we only specify which devices are reachable by each device.
func GenerateTopology ¶
GenerateTopology generates a Topology on the given DeviceSet. The affinity argument specifies the probability that any two devices are connected. We ensure that the generated topology is symmetric, but we do *not* guarantee that it is connected. TODO(nlacasse): Have more fine-grained affinity taking into account the DeviceSpec of each device. E.g. Desktop is likely to be connected to the cloud, but less likely to be connected to a watch.
type Universe ¶
type Universe struct { // All users in the universe. Users UserSet // Description of device connectivity. Topology Topology }
func GenerateUniverse ¶
func GenerateUniverse(opts UniverseOpts) Universe
func (*Universe) Databases ¶
func (u *Universe) Databases() DatabaseSet
Databases returns all databases contained in the universe.
type UniverseOpts ¶
type UniverseOpts struct { // Probability that any two devices are connected DeviceAffinity float64 // Maximum number of databases in the universe. MaxDatabases int // Number of users in the universe. NumUsers int // Maximum number of databases for any user. MaxDatabasesPerUser int // Maximum number of devices for any user. MaxDevicesPerUser int // Minimum number of devices for any user. MinDevicesPerUser int }
UniverseOpts specifies the options to use when creating a random universe.
type User ¶
type User struct { // The user's name. Name string // The user's devices. All databases in the user's devices will be // included in the user's Databases. Devices DeviceSet }
User represents a user.
func GenerateUser ¶
func GenerateUser(dbs DatabaseSet, opts UserOpts) *User
GenerateUser generates a random user with nonempty set of databases from the given database set and n devices. TODO(nlacasse): Should DatabaseSet be in UserOpts?
func (*User) Databases ¶
func (user *User) Databases() DatabaseSet
Databases returns all databases contained on the user's devices.