Documentation ¶
Overview ¶
The interfaces package aims to describe all interfaces available to modules.
Index ¶
- type Channel
- type Channels
- type Client
- type Conducting
- type Context
- type Db
- type Directory
- type Display
- type Document
- type DocumentPointer
- type Event
- type Events
- type File
- type FileInfo
- type FileSys
- type Filter
- type Hook
- type Hooks
- type Id
- type Instance
- type Method
- type Modifiers
- type Module
- type NestedData
- type NonPortable
- type Options
- type QueryMod
- type ReadableFile
- type Session
- type Set
- type Speaker
- type Subscriber
- type Temporaries
- type User
- type ViewContext
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channels ¶
Channels are used as a last resort of passing data trough the system. Caution, nothing like the channels in Go.
type Client ¶
type Client interface { StoreEncrypted(string, interface{}) error Store(string, interface{}) error Get(string) (interface{}, error) GetDecrypted(string) (interface{}, error) Unstore(string) error Languages() []string }
The client allows you to store and retrieve data at the client.
type Conducting ¶
type Context ¶
type Context interface { Conducting() Conducting FileSys() FileSys User() User Client() Client Db() Db Channels() Channels ViewContext() ViewContext NonPortable() NonPortable Display() Display Options() Options }
This contains everything modules can access.
type Db ¶
type Db interface { NewFilter(string, map[string]interface{}) (Filter, error) ToId(string) (Id, error) NewId() Id Session() (Session, error) }
Db represents a database. The NewFilter gives you filtered access to a certain collection. (Except if you have no rights at all, then gives error)
type Directory ¶
type Directory interface { File(...string) File Directory(...string) Directory Remove() error Exists() (bool, error) List() ([]FileInfo, error) Create() error Rename(string) error Name() string Path() string }
A directory will never allow you to access a directory or file residing in any of its parent directory. For accessing directories see the SelectPlace method of interface FileSys.
type Document ¶
type Document interface { Data() map[string]interface{} Id() Id Update(map[string]interface{}) error Remove() error }
Document represents a database document.
type DocumentPointer ¶
type DocumentPointer interface { Get() (Document, error) Update(map[string]interface{}) error Remove() error Id() Id }
Unused atm,it's just a draft.
type Events ¶
With events one can trigger events and send messages cross-process, cross-machine or cross-network.
type File ¶
type File interface { Create() error Exists() (bool, error) Write([]byte) error Read() ([]byte, error) Remove() error Rename(string) error Name() string Path() string // This is mostly here to be compatible with http.ServeFile }
We will have to adjust this to allow handling large files.
type FileSys ¶
type FileSys interface { // With the help of the SelectPlace one can (only) access // predefined places in the filesystem, eg: "modules" is mapped to /modules, // "template" is mapped to the current template in use, etc... SelectPlace(string) (Directory, error) Temporaries() Temporaries }
FileSys is everything you can with your filesystem.
type Filter ¶
type Filter interface { // Returns the Ids of the documents in the filtered set. Ids() ([]Id, error) // AddQuery will further filter the already filtered set. A filter should never refer to a larger subset of the set after the // AddQuery operation than before it. AddQuery(map[string]interface{}) Filter // Cloning a filter allows you to "branch" your filters. // Eg: (pseudocode) // fa := Filter{a:2} // fb := fa.Clone().AddQuery({b:3}) (equals: Filter{a:2,b:3}) // fc := fa.Clone().AddQuery({d:4}) (equals: Filter{a:2,d:4}) Clone() Filter // Reducing filters is a way to query foreign key relationships. Reduce(...Filter) (Filter, error) // Subject returns you the collectionname the filter refers to. Subject() string AddParents(string, []Id) Modifiers() Modifiers Count() (int, error) Iterate(func(Document) error) error // -- FindOne() (map[string]interface{}, error) Find() ([]map[string]interface{}, error) SelectOne() (Document, error) Insert(map[string]interface{}) error // InsertAll([]map[string]interface{}) errors Update(map[string]interface{}) error UpdateAll(map[string]interface{}) (int, error) Remove() error RemoveAll() (int, error) }
A filter is a collection of data, where you only have access to a subset of the whole set. See interface Set for further information.
type Hook ¶
type Hook interface { Subscribers() []Subscriber HasSubscribers() bool SubscriberCount() int Fire(params ...interface{}) Iterate(stopfunc interface{}, params ...interface{}) }
The Fire method is simply runs all modules subscribed to the given hook. With Iterate, one can provide a stop function as a first parameter, which will recieve the output of all hooks. If the stop function returns true, the execution of subscribers stop.
type Id ¶
type Id interface { IAmAnId() String() string }
Id represents a document Id. IAmAnId is there because too many things implement the interface { String() string }
type Instance ¶
type Instance interface { HasMethod(string) bool // Returns true if the Instance has a method with the name supplied. MethodNames() []string // Returns all public method names of Instance. Method(string) Method }
An instance is an empty instance of a given type. To convert an instance of any type to an Instance, see /frame/mod.ToInstance(interface{})
type Method ¶
type Method interface { Call(interface{}, ...interface{}) error // First param is the return reciever function, others are input arguments for the Method. Matches(interface{}) bool // Returns true if the Method matches the signature of the supplied function. InputTypes() []reflect.Type OutputTypes() []reflect.Type }
type Modifiers ¶
Modifiers are used to modify the querying of a collection, see interfaces Fiter and Set.
type Module ¶
Module is a package/module selector. Used to get around the lack of dynamic code loading.
type NestedData ¶
type NestedData interface { Get(...string) (interface{}, bool) GetI(...string) (int64, bool) GetF(...string) (float64, bool) GetM(...string) (map[string]interface{}, bool) GetS(...string) ([]interface{}, bool) GetStr(...string) (string, bool) Exists(...string) bool All() interface{} }
Helper interface to handle multiply nested data structures (eg. JSON). Should support dot notation ("subscribers.Johnny.age").
type NonPortable ¶
type NonPortable interface { Resource() string Params() map[string]interface{} Redirect(string) // Not sure about this. ComingFrom() string View() bool RawParams() string ServeFile(File) error ServeDir(Directory) error }
Maybe this could be called request.
type Options ¶
type Options interface { Document() NestedData Modifiers() NestedData }
Document() gives you back the option document, Modifiers() returns parameters specified by the client (eg. json=true).
type ReadableFile ¶
Readable file provides a subset of the functionality provided by the interace File: it can be read only. (Used at uploaded temporary files)
type Set ¶
type Set interface { QueryMod Count(map[string]interface{}) (int, error) FindOne(map[string]interface{}) (map[string]interface{}, error) Find(map[string]interface{}) ([]map[string]interface{}, error) Insert(map[string]interface{}) error // InsertAll([]map[string]interface{}) errors Update(map[string]interface{}, map[string]interface{}) error UpdateAll(map[string]interface{}, map[string]interface{}) (int, error) Remove(map[string]interface{}) error RemoveAll(map[string]interface{}) (int, error) Name() string }
Set represents a collection of data, mainly data coming from a database. See interface Filter for further information.
type Speaker ¶
Speaker is used to decipher the request path - it can tell if a string is a registered noun, and if that noun has a given verb defined on it.
type Subscriber ¶
type Temporaries ¶
type Temporaries interface { Select(string) []ReadableFile Exists(string) bool Keys() []string }
A way of accessing uploaded files without getting too involved in implementation details.
type ViewContext ¶
type ViewContext interface { Publish(string, interface{}) ViewContext Get() map[string]interface{} }
ViewContext contains the data the views has access to.