Port(Hexagonal Architecture)
Information
Port is entry/exit point to/from Business Logic. They are defined in the abstract part of the application. Entry point ports are a set of interfaces that define the operations the application can perform. Exit point ports define external resources that application will require to work. Ports are a part of Hexagonal Architecture. Entry point ports are used by input adapters. Implementations of exit points are called output adapters.
Examples
Note that in the examples below, argument and return structs are defined in the same package as the interface.
Entry points:
type InputGraph struct {
...
}
type OutputGraph struct {
...
}
type Translator interface {
Translate(InputGraph) (OutputGraph, error)
}
type BidRequest struct {
...
}
type BidResponse struct {
...
}
type Bidder interface {
Bid(BidRequest) (BidResponse, error)
}
type UpdateRequest struct {
...
}
type User struct {
...
}
type Updater interface {
Update(UpdateRequest) (User, error)
}
Exit points:
type User struct {
...
}
type Repository interface {
GetUser(id string) (User, error)
}
type Query struct {
...
}
type Result struct {
...
}
type Search interface {
Search(Query) (Result, error)
}
Resources
- its a part of Hexagonal Architecture, so look there