By default, the model signature output name alongside the model prediction gets used to produce cachable output. This can be customized by implementing a custom transformer.
A custom transformer has to use the following function signature:
type Transformer func(ctx context.Context, signature *Signature, input *gtly.Object, output interface{}) (common.Storable, error)
Then to register the transformer:
import "github.com/viant/mly/service/domain/transformer"
func init() {
transformer.Register("myTransformer", aTransformer)
}
Optionally you can implement a storable
provider.
import "github.com/viant/mly/service/domain/transformer"
func init() {
transformer.Register("myType", func() interface{} {
return &MyOutputType{}
})
}
Where MyOutputType
could implement the following interfaces to avoid reflection:
- Storable (Aerospike storage)
- Bintly (in-memory serialization)
- Gojay JSON (HTTP response)