func NewEvent(ctx context.Context, name EventName, payload interface{}) (IEvent, error) {
	// check if the event is registered in the registry
	t, err := Registry.GetEventInfo(name)
	if err != nil {
		return nil, err
	}

	if t.isValidPayload != nil {
		ok := t.isValidPayload(payload)
		if !ok {
			return nil, ErrInvalidPayload
		}
	} else {
		return nil, fmt.Errorf("payload checker is not set for event: %s", name)
	}

	e := &Event{Meta: getEventMeta(ctx, string(name)), Payload: payload}

	return e, nil
}
// NewEvent is the factory to generate all the event
NewEvent is the factory to generate all the event
// NewEvent is the factory to generate all the event
func NewEvent(ctx context.Context, name EventName, payload interface{}) (IEvent, error) {
	t, err := Registry.GetEventInfo(name)
	if err != nil {
		return nil, err
	}
	if t.isValidPayload != nil {
		ok := t.isValidPayload(payload)
		if !ok {
			return nil, ErrInvalidPayload
		}
	} else {
		return nil, fmt.Errorf("payload checker is not set for event: %s", name)
	}
	e := &Event{Meta: getEventMeta(ctx, string(name)), Payload: payload}
	return e, nil
}
func NewEvent ( ctx context . Context , name EventName , payload interface { } ) ( IEvent , error ) { t , err := Registry . GetEventInfo ( name ) if err != nil { return nil , err } if t . isValidPayload != nil { ok := t . isValidPayload ( payload ) if ! ok { return nil , ErrInvalidPayload } } else { return nil , fmt . Errorf ( " " , name ) } e := & Event { Meta : getEventMeta ( ctx , string ( name ) ) , Payload : payload } return e , nil }
NewEvent is the factory to generate all the event
NewEvent is the factory to generate all the event
// check if the event is registered in the registry