Documentation
¶
Overview ¶
Package ticket provides ticket domain models and business logic.
Index ¶
- Constants
- func RegisterTicketServiceServer(s interface{}, srv TicketServiceServer)
- type Article
- type Attachment
- type CacheService
- type CreateTicketRequest
- type CreateTicketResponse
- type DeleteTicketRequest
- type DeleteTicketResponse
- type Event
- type EventBus
- type EventHandler
- type GetTicketRequest
- type GetTicketResponse
- type HistoryItem
- type ListFilter
- type ListTicketsRequest
- type ListTicketsResponse
- type MetricsCollector
- type SearchTicketsRequest
- type SearchTicketsResponse
- type Ticket
- type TicketProto
- type TicketRepository
- type TicketService
- func (s *TicketService) CreateTicket(ctx context.Context, req *CreateTicketRequest) (*CreateTicketResponse, error)
- func (s *TicketService) GetTicket(ctx context.Context, req *GetTicketRequest) (*GetTicketResponse, error)
- func (s *TicketService) ListTickets(ctx context.Context, req *ListTicketsRequest) (*ListTicketsResponse, error)
- func (s *TicketService) SearchTickets(ctx context.Context, req *SearchTicketsRequest) (*SearchTicketsResponse, error)
- func (s *TicketService) Start(port int) error
- func (s *TicketService) UpdateTicket(ctx context.Context, req *UpdateTicketRequest) (*UpdateTicketResponse, error)
- type TicketServiceServer
- type UnimplementedTicketServiceServer
- func (UnimplementedTicketServiceServer) CreateTicket(context.Context, *CreateTicketRequest) (*CreateTicketResponse, error)
- func (UnimplementedTicketServiceServer) DeleteTicket(context.Context, *DeleteTicketRequest) (*DeleteTicketResponse, error)
- func (UnimplementedTicketServiceServer) GetTicket(context.Context, *GetTicketRequest) (*GetTicketResponse, error)
- func (UnimplementedTicketServiceServer) ListTickets(context.Context, *ListTicketsRequest) (*ListTicketsResponse, error)
- func (UnimplementedTicketServiceServer) SearchTickets(context.Context, *SearchTicketsRequest) (*SearchTicketsResponse, error)
- func (UnimplementedTicketServiceServer) UpdateTicket(context.Context, *UpdateTicketRequest) (*UpdateTicketResponse, error)
- type UpdateTicketRequest
- type UpdateTicketResponse
Constants ¶
const ( PriorityLow = "low" PriorityNormal = "normal" PriorityHigh = "high" PriorityUrgent = "urgent" PriorityCritical = "critical" )
Priority levels.
const ( StatusOpen = "open" StatusPending = "pending" StatusInProgress = "in_progress" StatusResolved = "resolved" StatusClosed = "closed" StatusOnHold = "on_hold" StatusCancelled = "cancelled" )
Status values.
const ( ArticleTypeEmail = "email" ArticleTypeNote = "note" ArticleTypePhone = "phone" ArticleTypeChat = "chat" ArticleTypeWeb = "web" )
Article types.
const ( ActionCreated = "created" ActionUpdated = "updated" ActionStatusChanged = "status_changed" ActionPriorityChanged = "priority_changed" ActionAssigned = "assigned" ActionCommented = "commented" ActionAttached = "attached" ActionMerged = "merged" ActionSplit = "split" ActionEscalated = "escalated" )
History actions.
Variables ¶
This section is empty.
Functions ¶
func RegisterTicketServiceServer ¶
func RegisterTicketServiceServer(s interface{}, srv TicketServiceServer)
RegisterTicketServiceServer registers the service with gRPC server.
Types ¶
type Article ¶
type Article struct {
ID string `json:"id" db:"id"`
TicketID string `json:"ticket_id" db:"ticket_id"`
Type string `json:"type" db:"type"` // email, note, phone, chat
From string `json:"from" db:"from_address"`
To string `json:"to" db:"to_address"`
Subject string `json:"subject" db:"subject"`
Body string `json:"body" db:"body"`
IsInternal bool `json:"is_internal" db:"is_internal"`
CreatedBy string `json:"created_by" db:"created_by"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
Attachments []Attachment `json:"attachments,omitempty"`
Metadata map[string]interface{} `json:"metadata" db:"metadata"`
}
Article represents a ticket article/message.
type Attachment ¶
type Attachment struct {
ID string `json:"id" db:"id"`
TicketID string `json:"ticket_id" db:"ticket_id"`
ArticleID *string `json:"article_id,omitempty" db:"article_id"`
FileName string `json:"file_name" db:"file_name"`
ContentType string `json:"content_type" db:"content_type"`
Size int64 `json:"size" db:"size"`
StoragePath string `json:"storage_path" db:"storage_path"`
UploadedBy string `json:"uploaded_by" db:"uploaded_by"`
UploadedAt time.Time `json:"uploaded_at" db:"uploaded_at"`
Checksum string `json:"checksum" db:"checksum"`
}
Attachment represents a file attachment.
type CacheService ¶
type CacheService interface {
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Delete(ctx context.Context, key string) error
Invalidate(ctx context.Context, pattern string) error
}
CacheService defines the interface for caching.
type CreateTicketRequest ¶
type CreateTicketResponse ¶
type CreateTicketResponse struct {
Ticket *TicketProto `json:"ticket"`
}
type DeleteTicketRequest ¶
type DeleteTicketRequest struct {
Id string `json:"id"`
}
type DeleteTicketResponse ¶
type DeleteTicketResponse struct {
Success bool `json:"success"`
}
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Data map[string]interface{} `json:"data"`
Source string `json:"source"`
Version string `json:"version"`
}
Event represents a domain event.
type EventBus ¶
type EventBus interface {
Publish(ctx context.Context, event Event) error
Subscribe(ctx context.Context, topic string, handler EventHandler) error
}
EventBus defines the interface for event publishing.
type EventHandler ¶
EventHandler processes events.
type GetTicketRequest ¶
type GetTicketRequest struct {
Id string `json:"id"`
}
type GetTicketResponse ¶
type GetTicketResponse struct {
Ticket *TicketProto `json:"ticket"`
}
type HistoryItem ¶
type HistoryItem struct {
ID string `json:"id" db:"id"`
TicketID string `json:"ticket_id" db:"ticket_id"`
Action string `json:"action" db:"action"`
Field string `json:"field" db:"field"`
OldValue *string `json:"old_value,omitempty" db:"old_value"`
NewValue *string `json:"new_value,omitempty" db:"new_value"`
ChangedBy string `json:"changed_by" db:"changed_by"`
ChangedAt time.Time `json:"changed_at" db:"changed_at"`
Comment string `json:"comment,omitempty" db:"comment"`
Metadata map[string]interface{} `json:"metadata" db:"metadata"`
}
HistoryItem represents a ticket history entry.
type ListFilter ¶
type ListFilter struct {
Status string `json:"status,omitempty"`
Priority string `json:"priority,omitempty"`
QueueID string `json:"queue_id,omitempty"`
AssignedTo string `json:"assigned_to,omitempty"`
CustomerID string `json:"customer_id,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedFrom time.Time `json:"created_from,omitempty"`
CreatedTo time.Time `json:"created_to,omitempty"`
UpdatedFrom time.Time `json:"updated_from,omitempty"`
UpdatedTo time.Time `json:"updated_to,omitempty"`
SortBy string `json:"sort_by,omitempty"`
SortOrder string `json:"sort_order,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
ListFilter represents ticket list filtering options.
func (*ListFilter) Hash ¶
func (f *ListFilter) Hash() string
Hash generates a hash of the filter for caching.
type ListTicketsRequest ¶
type ListTicketsResponse ¶
type ListTicketsResponse struct {
Tickets []*TicketProto `json:"tickets"`
Total int32 `json:"total"`
}
type MetricsCollector ¶
type MetricsCollector interface {
IncrementCounter(name string, labels map[string]string)
RecordDuration(name string, duration time.Duration, labels map[string]string)
SetGauge(name string, value float64, labels map[string]string)
}
MetricsCollector defines the interface for metrics collection.
type SearchTicketsRequest ¶
type SearchTicketsResponse ¶
type SearchTicketsResponse struct {
Tickets []*TicketProto `json:"tickets"`
Total int32 `json:"total"`
}
type Ticket ¶
type Ticket struct {
ID string `json:"id" db:"id"`
Number string `json:"number" db:"number"`
Title string `json:"title" db:"title"`
Description string `json:"description" db:"description"`
Priority string `json:"priority" db:"priority"`
Status string `json:"status" db:"status"`
QueueID string `json:"queue_id" db:"queue_id"`
CustomerID string `json:"customer_id" db:"customer_id"`
AssignedTo *string `json:"assigned_to,omitempty" db:"assigned_to"`
Tags []string `json:"tags" db:"tags"`
CustomFields map[string]interface{} `json:"custom_fields" db:"custom_fields"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
ResolvedAt *time.Time `json:"resolved_at,omitempty" db:"resolved_at"`
ClosedAt *time.Time `json:"closed_at,omitempty" db:"closed_at"`
DueAt *time.Time `json:"due_at,omitempty" db:"due_at"`
FirstResponseAt *time.Time `json:"first_response_at,omitempty" db:"first_response_at"`
// Relationships
Articles []Article `json:"articles,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
History []HistoryItem `json:"history,omitempty"`
}
Ticket represents a support ticket.
func (*Ticket) ToProto ¶
func (t *Ticket) ToProto() *TicketProto
ToProto converts the ticket to protobuf format.
type TicketProto ¶
type TicketProto struct {
Id string `json:"id"`
Number string `json:"number"`
Title string `json:"title"`
Description string `json:"description"`
Priority string `json:"priority"`
Status string `json:"status"`
QueueId string `json:"queue_id"`
CustomerId string `json:"customer_id"`
AssignedTo string `json:"assigned_to"`
Tags []string `json:"tags"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
ResolvedAt int64 `json:"resolved_at"`
ClosedAt int64 `json:"closed_at"`
DueAt int64 `json:"due_at"`
FirstResponseAt int64 `json:"first_response_at"`
}
TicketProto represents a ticket in protobuf format.
type TicketRepository ¶
type TicketRepository interface {
Create(ctx context.Context, ticket *Ticket) error
GetByID(ctx context.Context, id string) (*Ticket, error)
Update(ctx context.Context, ticket *Ticket) error
Delete(ctx context.Context, id string) error
List(ctx context.Context, filter *ListFilter) ([]*Ticket, error)
Search(ctx context.Context, query string) ([]*Ticket, error)
}
TicketRepository defines the interface for ticket data access.
type TicketService ¶
type TicketService struct {
UnimplementedTicketServiceServer
// contains filtered or unexported fields
}
TicketService handles all ticket-related operations as a microservice.
func NewTicketService ¶
func NewTicketService(repo TicketRepository, cache CacheService, events EventBus, metrics MetricsCollector) *TicketService
NewTicketService creates a new ticket service instance.
func (*TicketService) CreateTicket ¶
func (s *TicketService) CreateTicket(ctx context.Context, req *CreateTicketRequest) (*CreateTicketResponse, error)
CreateTicket creates a new ticket.
func (*TicketService) GetTicket ¶
func (s *TicketService) GetTicket(ctx context.Context, req *GetTicketRequest) (*GetTicketResponse, error)
GetTicket retrieves a ticket by ID.
func (*TicketService) ListTickets ¶
func (s *TicketService) ListTickets(ctx context.Context, req *ListTicketsRequest) (*ListTicketsResponse, error)
ListTickets lists tickets with filtering.
func (*TicketService) SearchTickets ¶
func (s *TicketService) SearchTickets(ctx context.Context, req *SearchTicketsRequest) (*SearchTicketsResponse, error)
SearchTickets searches tickets.
func (*TicketService) Start ¶
func (s *TicketService) Start(port int) error
Start starts the gRPC server.
func (*TicketService) UpdateTicket ¶
func (s *TicketService) UpdateTicket(ctx context.Context, req *UpdateTicketRequest) (*UpdateTicketResponse, error)
UpdateTicket updates an existing ticket.
type TicketServiceServer ¶
type TicketServiceServer interface {
CreateTicket(context.Context, *CreateTicketRequest) (*CreateTicketResponse, error)
GetTicket(context.Context, *GetTicketRequest) (*GetTicketResponse, error)
UpdateTicket(context.Context, *UpdateTicketRequest) (*UpdateTicketResponse, error)
DeleteTicket(context.Context, *DeleteTicketRequest) (*DeleteTicketResponse, error)
ListTickets(context.Context, *ListTicketsRequest) (*ListTicketsResponse, error)
SearchTickets(context.Context, *SearchTicketsRequest) (*SearchTicketsResponse, error)
}
gRPC Server interface.
type UnimplementedTicketServiceServer ¶
type UnimplementedTicketServiceServer struct{}
UnimplementedTicketServiceServer can be embedded to have forward compatible implementations.
func (UnimplementedTicketServiceServer) CreateTicket ¶
func (UnimplementedTicketServiceServer) CreateTicket(context.Context, *CreateTicketRequest) (*CreateTicketResponse, error)
func (UnimplementedTicketServiceServer) DeleteTicket ¶
func (UnimplementedTicketServiceServer) DeleteTicket(context.Context, *DeleteTicketRequest) (*DeleteTicketResponse, error)
func (UnimplementedTicketServiceServer) GetTicket ¶
func (UnimplementedTicketServiceServer) GetTicket(context.Context, *GetTicketRequest) (*GetTicketResponse, error)
func (UnimplementedTicketServiceServer) ListTickets ¶
func (UnimplementedTicketServiceServer) ListTickets(context.Context, *ListTicketsRequest) (*ListTicketsResponse, error)
func (UnimplementedTicketServiceServer) SearchTickets ¶
func (UnimplementedTicketServiceServer) SearchTickets(context.Context, *SearchTicketsRequest) (*SearchTicketsResponse, error)
func (UnimplementedTicketServiceServer) UpdateTicket ¶
func (UnimplementedTicketServiceServer) UpdateTicket(context.Context, *UpdateTicketRequest) (*UpdateTicketResponse, error)
type UpdateTicketRequest ¶
type UpdateTicketResponse ¶
type UpdateTicketResponse struct {
Ticket *TicketProto `json:"ticket"`
}