Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
RegisterHandlers sets up the routing of the HTTP handlers.
Types ¶
type Connection ¶
type Connection struct {
entity.Connection
}
Connection represents the data about an connection.
type CreateConnectionRequest ¶
type CreateConnectionRequest struct {
SelfID string `json:"selfid"`
}
CreateConnectionRequest represents an connection creation request.
func (CreateConnectionRequest) Validate ¶
func (m CreateConnectionRequest) Validate() *response.Error
Validate validates the CreateConnectionRequest fields.
type ExtConnection ¶
type ExtConnection struct { ID string `json:"id"` AppID string `json:"app_id"` Name string `json:"name"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
ExtConnection external representation of a connection.
type ExtListResponse ¶
type ExtListResponse struct { Page int `json:"page"` PerPage int `json:"per_page"` PageCount int `json:"page_count"` TotalCount int `json:"total_count"` Items []ExtConnection `json:"items"` }
ExtListResponse represents the json object returned when listing connections.
type FactService ¶
type FactService interface {
Request(*fact.FactRequest) (*fact.FactResponse, error)
}
FactService service to manage sending and receiving fact requests
type Repository ¶
type Repository interface { // Get returns the connection with the specified connection ID. Get(ctx context.Context, appID, selfID string) (entity.Connection, error) // Count returns the number of connections. Count(ctx context.Context, appID string) (int, error) // Query returns the list of connections with the given offset and limit. Query(ctx context.Context, appid string, offset, limit int) ([]entity.Connection, error) // Create saves a new connection in the storage. Create(ctx context.Context, connection entity.Connection) error // Update updates the connection with given ID in the storage. Update(ctx context.Context, connection entity.Connection) error // Delete removes the connection with given ID from the storage. Delete(ctx context.Context, id int) error }
Repository encapsulates the logic to access connections from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new connection repository
type Service ¶
type Service interface { Get(ctx context.Context, appid, selfid string) (Connection, error) Query(ctx context.Context, appid string, offset, limit int) ([]Connection, error) Count(ctx context.Context, appid string) (int, error) Create(ctx context.Context, appid string, input CreateConnectionRequest) (Connection, error) Update(ctx context.Context, appid, selfid string, input UpdateConnectionRequest) (Connection, error) Delete(ctx context.Context, appid, selfid string) (Connection, error) }
Service encapsulates usecase logic for connections.
func NewService ¶
func NewService(repo Repository, runner support.SelfClientGetter, logger log.Logger) Service
NewService creates a new connection service.
type UpdateConnectionRequest ¶
type UpdateConnectionRequest struct {
Name string `json:"name"`
}
UpdateConnectionRequest represents an connection update request.
func (UpdateConnectionRequest) Validate ¶
func (m UpdateConnectionRequest) Validate() *response.Error
Validate validates the CreateConnectionRequest fields.