storage

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetEventReceiverGroupEnabled

func SetEventReceiverGroupEnabled(tx *gorm.DB, id graphql.ID, enabled bool) error

Types

type Database

type Database struct {
	Client *gorm.DB
}

func New

func New(host, user, pass, sslMode, database string, port int) (*Database, error)

func (*Database) SyncSchema

func (db *Database) SyncSchema() error

type Event

type Event struct {
	ID          graphql.ID `json:"id" gorm:"type:varchar(255);primary_key;not null"`
	Name        string     `json:"name" gorm:"type:varchar(255);not null"`
	Version     string     `json:"version" gorm:"type:varchar(255);not null"`
	Release     string     `json:"release" gorm:"type:varchar(255);not null"`
	PlatformID  string     `json:"platform_id" gorm:"type:varchar(255);not null"`
	Package     string     `json:"package" gorm:"type:varchar(255);not null"`
	Description string     `json:"description" gorm:"type:varchar(255);not null"`
	Payload     types.JSON `json:"payload" gorm:"not null"`

	Success   bool       `json:"success" gorm:"not null"`
	CreatedAt types.Time `json:"created_at" gorm:"type:timestamptz; not null; default:CURRENT_TIMESTAMP"`

	EventReceiverID graphql.ID `json:"event_receiver_id" gorm:"type:varchar(255);not null"`
	EventReceiver   EventReceiver
}

Event type represents an event with various properties and a relationship to an event receiver.

func CreateEvent

func CreateEvent(tx *gorm.DB, event Event) (*Event, error)

CreateEvent creates and event record in the database. Throws an error if the event receiver does not exist or if the event payload does not match the receiver schema.

func EventFromJSON

func EventFromJSON(reader io.Reader) (*Event, error)

EventFromJSON reads JSON data from a reader and returns an Event object.

func FindEvent

func FindEvent(tx *gorm.DB, e map[string]any) ([]Event, error)

func FindEventByID

func FindEventByID(tx *gorm.DB, id graphql.ID) ([]Event, error)

func (*Event) ToJSON

func (e *Event) ToJSON() (string, error)

ToJSON() function is a method defined on the `Event` struct. It converts an instance of the `Event` struct to a JSON string representation.

func (*Event) ToYAML

func (e *Event) ToYAML() (string, error)

ToYAML() converts struct to a YAML string representation.

type EventReceiver

type EventReceiver struct {
	ID          graphql.ID `json:"id" gorm:"type:varchar(255);primary_key;not null"`
	Name        string     `json:"name" gorm:"type:varchar(255);not null"`
	Type        string     `json:"type" gorm:"type:varchar(255);not null"`
	Version     string     `json:"version" gorm:"type:varchar(255);not null"`
	Description string     `json:"description" gorm:"type:varchar(255);not null"`

	Schema      types.JSON `json:"schema" gorm:"not null"`
	Fingerprint string     `json:"fingerprint" gorm:"type:varchar(255);not null"`
	CreatedAt   types.Time `json:"created_at" gorm:"type:timestamptz;not null;default:CURRENT_TIMESTAMP"`
}

EventReceiver type represents an event receiver with various properties such as ID, name, type, version, etc...

func CreateEventReceiver

func CreateEventReceiver(tx *gorm.DB, eventReceiver EventReceiver) (*EventReceiver, error)

func EventReceiverFromJSON

func EventReceiverFromJSON(reader io.Reader) (*EventReceiver, error)

EventReceiverFromJSON reads JSON data from a reader and returns an EventReceiver object.

func FindEventReceiver

func FindEventReceiver(tx *gorm.DB, er map[string]any) ([]EventReceiver, error)

FindEventReceiver tries to find an event receiver by matching fields

func FindEventReceiverByID

func FindEventReceiverByID(tx *gorm.DB, id graphql.ID) ([]EventReceiver, error)

FindEventReceiverByID tries to find an event receiver by ID.

func (*EventReceiver) ToJSON

func (e *EventReceiver) ToJSON() (string, error)

ToJSON() converts an instance of a JSON string representation.

func (*EventReceiver) ToYAML

func (e *EventReceiver) ToYAML() (string, error)

ToYAML() converts struct to a YAML string representation.

type EventReceiverGroup

type EventReceiverGroup struct {
	ID          graphql.ID `json:"id" gorm:"type:varchar(255);primary_key;not null"`
	Name        string     `json:"name" gorm:"type:varchar(255);not null"`
	Type        string     `json:"type" gorm:"type:varchar(255);not null"`
	Version     string     `json:"version" gorm:"type:varchar(255);not null"`
	Description string     `json:"description" gorm:"type:varchar(255);not null"`
	Enabled     bool       `json:"enabled" gorm:"not null"`

	EventReceiverIDs []graphql.ID `json:"event_receiver_ids" gorm:"-"`

	CreatedAt types.Time `json:"created_at" gorm:"type:timestamptz; not null; default:CURRENT_TIMESTAMP"`
	UpdatedAt types.Time `json:"updated_at" gorm:"type:timestamptz; not null; default:CURRENT_TIMESTAMP"`
}

EventReceiverGroup represents a group of event receivers with various properties.

func CreateEventReceiverGroup

func CreateEventReceiverGroup(tx *gorm.DB, eventReceiverGroup EventReceiverGroup) (*EventReceiverGroup, error)

func EventReceiverGroupFromJSON

func EventReceiverGroupFromJSON(reader io.Reader) (*EventReceiverGroup, error)

EventReceiverGroupFromJSON reads JSON data from a reader and returns an EventReceiverGroup object.

func FindEventReceiverGroup

func FindEventReceiverGroup(tx *gorm.DB, erg map[string]any) ([]EventReceiverGroup, error)

func FindEventReceiverGroupByID

func FindEventReceiverGroupByID(tx *gorm.DB, id graphql.ID) ([]EventReceiverGroup, error)

func FindTriggeredEventReceiverGroups

func FindTriggeredEventReceiverGroups(tx *gorm.DB, event Event) ([]EventReceiverGroup, error)

func (*EventReceiverGroup) ToJSON

func (e *EventReceiverGroup) ToJSON() (string, error)

ToJSON() converts struct to a JSON string representation.

func (*EventReceiverGroup) ToYAML

func (e *EventReceiverGroup) ToYAML() (string, error)

ToYAML() converts struct to a YAML string representation.

type EventReceiverGroupToEventReceiver

type EventReceiverGroupToEventReceiver struct {
	ID int `json:"id" gorm:"primaryKey;autoIncrement"`

	EventReceiverID graphql.ID `json:"event_receiver_id" gorm:"type:varchar(255);not null"`
	EventReceiver   EventReceiver

	EventReceiverGroup   EventReceiverGroup
	EventReceiverGroupID graphql.ID `json:"event_receiver_group_id" gorm:"type:varchar(255);not null"`
}

EventReceiverGroupToEventReceiver represents the relationship between an

type TriggeredEventReceiverGroups

type TriggeredEventReceiverGroups struct {
	EventReceiverGroup

	// Database returns json array instead of a string
	EventReceiverIDs types.JSON `json:"event_receiver_ids"`
}

Data represents the EventReceiverGroup data that comes back from the mega query. It is necessary to allow us to automatically insert event_receiver_ids by overriding the json tag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL