Documentation ¶
Index ¶
- func GetKey(x proto.Message) (string, error)
- func GetModel(x proto.Message) (registeredModel, error)
- func GetModelForKey(key string) (registeredModel, error)
- func GetName(x proto.Message) (string, error)
- func GetPath(x proto.Message) (string, error)
- func ItemKey(item *api.Item) (string, error)
- func Key(x proto.Message) string
- func MarshalItem(pb proto.Message) (*api.Item, error)
- func Model(x proto.Message) registeredModel
- func ModelForItem(item *api.Item) (registeredModel, error)
- func Name(x proto.Message) string
- func Path(x proto.Message) string
- func Register(pb proto.Message, spec Spec, opts ...ModelOption) *registeredModel
- func RegisteredModels() (models []*api.ModelInfo)
- func UnmarshalItem(m *api.Item) (proto.Message, error)
- func UnmarshalLazyValue(key string, lazy datasync.LazyValue) (proto.Message, error)
- type ModelOption
- type NameFunc
- type Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetKey ¶
GetKey returns complete key for gived model, including key prefix defined by model specification. It returns error if given model is not registered.
func GetModel ¶
GetModel returns registered model for the given proto message.
func GetModelForKey ¶
GetModelForKey returns registered model for the given key or error.
func GetPath ¶
GetKeyPrefix returns key prefix for gived model. It returns error if given model is not registered.
func Key ¶
Key is a shorthand for the GetKey for avoid error checking.
func MarshalItem ¶
Marshal is helper function for marshalling items.
func Model ¶
Model returns registered model for the given proto message.
func Name ¶
Name is a shorthand for the GetName for avoid error checking.
func Path ¶
Path is a shorthand for the GetPath for avoid error checking.
func Register ¶
func Register(pb proto.Message, spec Spec, opts ...ModelOption) *registeredModel
Register registers the protobuf message with given model specification.
func RegisteredModels ¶
RegisteredModels returns all registered modules.
func UnmarshalItem ¶
Unmarshal is helper function for unmarshalling items.
Types ¶
type ModelOption ¶
type ModelOption func(*modelOptions)
ModelOption defines function type which sets model options.
func WithNameTemplate ¶
func WithNameTemplate(t string) ModelOption
WithNameTemplate returns option for models which sets function for generating name of instances using custom template.
type NameFunc ¶
NameFunc represents function which can name model instance.