Documentation
¶
Index ¶
- Variables
- type CreateTermInput
- type GlossaryTerm
- type ListResult
- type MetricsClient
- type Owner
- type OwnerInput
- type PostgresRepository
- func (r *PostgresRepository) Create(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
- func (r *PostgresRepository) Get(ctx context.Context, id string) (*GlossaryTerm, error)
- func (r *PostgresRepository) GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
- func (r *PostgresRepository) List(ctx context.Context, offset, limit int) (*ListResult, error)
- func (r *PostgresRepository) Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
- func (r *PostgresRepository) Update(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
- type Repository
- type SearchFilter
- type Service
- type ServiceOption
- type UpdateTermInput
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidInput = errors.New("invalid input") ErrTermNotFound = errors.New("glossary term not found") ErrTermExists = errors.New("glossary term already exists") ErrCircularRef = errors.New("circular reference detected in term hierarchy") )
View Source
var ( ErrNotFound = errors.New("glossary term not found") ErrConflict = errors.New("glossary term with this name already exists") )
Functions ¶
This section is empty.
Types ¶
type CreateTermInput ¶
type CreateTermInput struct {
Name string `json:"name" validate:"required,min=1,max=255"`
Definition string `json:"definition" validate:"required,min=1"`
Description *string `json:"description,omitempty"`
ParentTermID *string `json:"parent_term_id,omitempty"`
Owners []OwnerInput `json:"owners" validate:"required,min=1,dive"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type GlossaryTerm ¶
type GlossaryTerm struct {
ID string `json:"id"`
Name string `json:"name"`
Definition string `json:"definition"`
Description *string `json:"description,omitempty"`
ParentTermID *string `json:"parent_term_id,omitempty"`
Owners []Owner `json:"owners"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
type ListResult ¶
type ListResult struct {
Terms []*GlossaryTerm `json:"terms"`
Total int `json:"total"`
}
type MetricsClient ¶
type OwnerInput ¶
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *pgxpool.Pool, recorder metrics.Recorder) *PostgresRepository
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
func (*PostgresRepository) Get ¶
func (r *PostgresRepository) Get(ctx context.Context, id string) (*GlossaryTerm, error)
func (*PostgresRepository) GetChildren ¶
func (r *PostgresRepository) GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
func (*PostgresRepository) List ¶
func (r *PostgresRepository) List(ctx context.Context, offset, limit int) (*ListResult, error)
func (*PostgresRepository) Search ¶
func (r *PostgresRepository) Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
func (*PostgresRepository) Update ¶
func (r *PostgresRepository) Update(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
type Repository ¶
type Repository interface {
Create(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
Get(ctx context.Context, id string) (*GlossaryTerm, error)
Update(ctx context.Context, term *GlossaryTerm, owners []OwnerInput) error
List(ctx context.Context, offset, limit int) (*ListResult, error)
Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
}
type SearchFilter ¶
type SearchFilter struct {
Query string `json:"query,omitempty"`
ParentTermID *string `json:"parent_term_id,omitempty"`
OwnerIDs []string `json:"owner_ids,omitempty"`
Limit int `json:"limit,omitempty" validate:"omitempty,gte=0,lte=100"`
Offset int `json:"offset,omitempty" validate:"omitempty,gte=0"`
}
type Service ¶
type Service interface {
Create(ctx context.Context, input CreateTermInput) (*GlossaryTerm, error)
Get(ctx context.Context, id string) (*GlossaryTerm, error)
Update(ctx context.Context, id string, input UpdateTermInput) (*GlossaryTerm, error)
Delete(ctx context.Context, id string) error
List(ctx context.Context, offset, limit int) (*ListResult, error)
Search(ctx context.Context, filter SearchFilter) (*ListResult, error)
GetChildren(ctx context.Context, parentID string) ([]*GlossaryTerm, error)
GetAncestors(ctx context.Context, termID string) ([]*GlossaryTerm, error)
}
func NewService ¶
func NewService(repo Repository, opts ...ServiceOption) Service
type ServiceOption ¶
type ServiceOption func(*service)
func WithMetrics ¶
func WithMetrics(metrics MetricsClient) ServiceOption
type UpdateTermInput ¶
type UpdateTermInput struct {
Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=255"`
Definition *string `json:"definition,omitempty" validate:"omitempty,min=1"`
Description *string `json:"description,omitempty"`
ParentTermID *string `json:"parent_term_id,omitempty"`
Owners []OwnerInput `json:"owners,omitempty" validate:"omitempty,min=1,dive"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Tags []string `json:"tags,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.