domain

package
v0.0.0-...-833cb33 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusDone    = "STATUS_DONE"
	StatusPending = "STATUS_PENDING"
	Book          = "MEDIA_BOOK"
	Podcast       = "MEDIA_PODCAST"
	Doc           = "MEDIA_DOC"
	Video         = "MEDIA_VIDEO"
)
View Source
const (
	MediaUpdated     = "MEDIA_UPDATED"
	MediaRemoved     = "MEDIA_REMOVED"
	MediaRestored    = "MEDIA_RESTORED"
	MediaHardRemoved = "MEDIA_PERMANENTLY_REMOVED"
)
View Source
const (
	// Side-effect events
	MediaCreated = "MEDIA_CREATED" // Produced

	// Foreign validation events
	OwnerVerify    = "OWNER_VERIFY"          // Produced
	OwnerVerified  = "MEDIA_OWNER_VERIFIED"  // Consumed
	OwnerFailed    = "MEDIA_OWNER_FAILED"    // Consumed
	AuthorVerify   = "AUTHOR_VERIFY"         // Produced
	AuthorVerified = "MEDIA_AUTHOR_VERIFIED" // Consumed
	AuthorFailed   = "MEDIA_AUTHOR_FAILED"   // Consumed
	BlobUploaded   = "MEDIA_BLOB_UPLOADED"   // Consumed
	BlobRemoved    = "MEDIA_BLOB_REMOVED"    // Consumed
	BlobFailed     = "BLOB_FAILED"           // Produced
)

Variables

This section is empty.

Functions

func ParseDate

func ParseDate(date string) (time.Time, error)

func ParseMediaType

func ParseMediaType(media string) string

Types

type Media

type Media struct {
	ID          int64  `json:"-"`
	ExternalID  string `json:"id" validate:"required"`
	Title       string `json:"title" validate:"required,min=1,max=255"`
	DisplayName string `json:"display_name" validate:"required,min=1,max=128"`
	Description string `json:"description" validate:"max=1024"`
	// ISO 639-2 Alpha-3 lang code
	LanguageCode string `json:"language_code" validate:"alphaunicode"`
	// User ID, Required SAGA transaction
	PublisherID string `json:"publisher_id"`
	// Required SAGA transaction
	AuthorID string `json:"author_id"`
	// Content's publish date
	PublishDate time.Time  `json:"publish_date"`
	MediaType   string     `json:"media_type" validate:"required,oneof=MEDIA_BOOK MEDIA_VIDEO MEDIA_DOC MEDIA_PODCAST"`
	CreateTime  time.Time  `json:"create_time"`
	UpdateTime  time.Time  `json:"update_time"`
	DeleteTime  *time.Time `json:"delete_time"`
	Active      bool       `json:"active"`
	ContentURL  *string    `json:"content_url"`
	TotalViews  int64      `json:"total_views"`
	Status      string     `json:"status" validate:"required,oneof=STATUS_DONE STATUS_PENDING"`
}

func NewMedia

func NewMedia(ag *MediaAggregate) (*Media, error)

func (*Media) IsValid

func (m *Media) IsValid() error

type MediaAggregate

type MediaAggregate struct {
	Title        string `json:"title"`
	DisplayName  string `json:"display_name"`
	Description  string `json:"description"`
	LanguageCode string `json:"language_code"`
	PublisherID  string `json:"publisher_id"`
	AuthorID     string `json:"author_id"`
	PublishDate  string `json:"publish_date"`
	MediaType    string `json:"media_type"`
}

type MediaEvent

type MediaEvent interface {
	StartCreate(ctx context.Context, media Media) error
	StartUpdate(ctx context.Context, media Media, snapshot Media) error
	Updated(ctx context.Context, media Media) error
	Removed(ctx context.Context, id string) error
	Restored(ctx context.Context, id string) error
	HardRemoved(ctx context.Context, id string) error
}

type MediaEventSAGA

type MediaEventSAGA interface {
	VerifyAuthor(ctx context.Context, authors []string) error
	Created(ctx context.Context, media Media) error
	BlobFailed(ctx context.Context, msg string) error
}

type MediaRepository

type MediaRepository interface {
	Save(ctx context.Context, media Media) error
	SaveRaw(ctx context.Context, media Media) error
	Fetch(ctx context.Context, params core.PaginationParams, filter core.FilterParams) ([]*Media, error)
	FetchByID(ctx context.Context, id string, showDisabled bool) (*Media, error)
	Replace(ctx context.Context, media Media) error
	Remove(ctx context.Context, id string) error
	Restore(ctx context.Context, id string) error
	HardRemove(ctx context.Context, id string) error
	ChangeState(ctx context.Context, id, state string) error
}

type MediaUpdateAggregate

type MediaUpdateAggregate struct {
	Root *MediaAggregate
	ID   string `json:"id"`
	URL  string `json:"url"`
}

Jump to

Keyboard shortcuts

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