Documentation
¶
Index ¶
- Variables
- func FromJSON(buf []byte, data interface{}) error
- func ToJSON(data interface{}) ([]byte, error)
- type JSONProperties
- func (x *JSONProperties) LockForRead(key string) *SyncedJSONProperty
- func (x *JSONProperties) LockForWrite(key string) *SyncedJSONProperty
- func (x *JSONProperties) Lookup(key string) bool
- func (x *JSONProperties) MarshalJSON() ([]byte, error)
- func (x *JSONProperties) SetModule(module string)
- func (x *JSONProperties) UnmarshalJSON(b []byte) error
- type Property
- type Serializable
- type SyncedJSONProperty
Constants ¶
This section is empty.
Variables ¶
var PropertyTypeRegistry = struct{ propertyTypeRegistry }{/* contains filtered or unexported fields */}
PropertyTypeRegistry ...
Functions ¶
Types ¶
type JSONProperties ¶
type JSONProperties struct { Properties jsonProperties // This lock is used to make sure addition or removal of keys in JSonProperties won't collide in go routines sync.Mutex // contains filtered or unexported fields }
JSONProperties ...
func NewJSONProperties ¶
func NewJSONProperties(module string) *JSONProperties
NewJSONProperties creates a new JSonProperties instance
func (*JSONProperties) LockForRead ¶
func (x *JSONProperties) LockForRead(key string) *SyncedJSONProperty
LockForRead is used to lock an extension for read Returns a pointer to LockedEncodedExtension, on which can be applied method 'Use()' If no extension exists corresponding to the key, an empty extension is created (in other words, this call cannot fail because a key doesn't exist).
func (*JSONProperties) LockForWrite ¶
func (x *JSONProperties) LockForWrite(key string) *SyncedJSONProperty
LockForWrite is used to lock an extension for write Returns a pointer to LockedEncodedExtension, on which can be applied method 'Use()' If no extension exists corresponding to the key, an empty one is created (in other words, this call cannot fail because a key doesn't exist).
func (*JSONProperties) Lookup ¶
func (x *JSONProperties) Lookup(key string) bool
Lookup tells if a key is present in JSonProperties
func (*JSONProperties) MarshalJSON ¶
func (x *JSONProperties) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller Note: DO NOT LOCK property here, deadlock risk
func (*JSONProperties) SetModule ¶
func (x *JSONProperties) SetModule(module string)
SetModule allows to change the module of the JSONProperties (used to "contextualize" Property Types)
func (*JSONProperties) UnmarshalJSON ¶
func (x *JSONProperties) UnmarshalJSON(b []byte) error
UnmarshalJSON implement json.Unmarshaller Note: DO NOT LOCK property here, deadlock risk
type Property ¶
type Property interface { // Content allows to access real data from property Content() interface{} // Clone allows to duplicate Property Clone() Property // Replace allows to replace Property with data from source Replace(Property) Property }
Property is the interface each Property must satisfy
type Serializable ¶
Serializable is the interface allowing the conversion of satisfying struct to []byte (Serialize()) and reverse operation (Unserialize())
type SyncedJSONProperty ¶
type SyncedJSONProperty struct {
// contains filtered or unexported fields
}
SyncedJSONProperty is used to manipulate jsonProperty with type of lock asked (as returns by JSONProperties.LockBy<x>)
func (SyncedJSONProperty) MarshalJSON ¶
MarshalJSON (json.Marshaller interface)
func (*SyncedJSONProperty) ThenUse ¶
func (sp *SyncedJSONProperty) ThenUse(apply func(interface{}) error) (err error)
ThenUse allows to run a function with 'key' decoded content passed as parameter after a call to JSonProperties.LockForRead() or JSonProperties.LockForWrite(). If the extension is locked for write, changes to the decoded data are encoded back into the extension on 'apply' success. If the extension is locked for read, no change will be encoded into the extension. The lock applied on the extension is automatically released on exit.