Пример #1
0
func (runner *SyncRunner) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, userCtx map[string]interface{}) (*ChannelMapperOutput, error) {
	result, err := runner.Call(body, sgbucket.JSONString(oldBodyJSON), userCtx)
	if err != nil {
		return nil, err
	}
	return result.(*ChannelMapperOutput), nil
}
Пример #2
0
func (mapper *ChannelMapper) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, userCtx map[string]interface{}) (*ChannelMapperOutput, error) {
	result1, err := mapper.Call(body, sgbucket.JSONString(oldBodyJSON), userCtx)
	if err != nil {
		return nil, err
	}
	output := result1.(*ChannelMapperOutput)
	return output, nil
}
Пример #3
0
// Calls a jsEventFunction returning an interface{}
func (ef *JSEventFunction) CallFunction(event Event) (interface{}, error) {

	var err error
	var result interface{}

	// Different events send different parameters
	switch event := event.(type) {

	case *DocumentChangeEvent:
		result, err = ef.Call(event.Doc, sgbucket.JSONString(event.OldDoc))
	case *DBStateChangeEvent:
		result, err = ef.Call(event.Doc)
	}

	if err != nil {
		base.Warn("Error calling function - function processing aborted: %v", err)
		return "", err
	}

	return result, err
}