profile

package
v1.0.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MakeAddFollowerEndpoint

func MakeAddFollowerEndpoint(s Service) endpoint.Endpoint

MakeAddFollowerEndpoint returns an endpoint that invokes AddFollower on the service.

func MakeDeleteFollowerEndpoint

func MakeDeleteFollowerEndpoint(s Service) endpoint.Endpoint

MakeDeleteFollowerEndpoint returns an endpoint that invokes AddFollower on the service.

func MakeListEndpoint

func MakeListEndpoint(s Service) endpoint.Endpoint

MakeListEndpoint returns an endpoint that invokes List on the service.

func MakeListFollowersEndpoint

func MakeListFollowersEndpoint(s Service) endpoint.Endpoint

MakeListFollowersEndpoint returns an endpoint that invokes ListFollowers on the service.

func MakeListFollowingsEndpoint

func MakeListFollowingsEndpoint(s Service) endpoint.Endpoint

MakeListFollowingsEndpoint returns an endpoint that invokes ListFollowings on the service.

func MakeReadEndpoint

func MakeReadEndpoint(s Service) endpoint.Endpoint

MakeReadEndpoint returns an endpoint that invokes Read on the service.

func MakeUpsertEndpoint

func MakeUpsertEndpoint(s Service) endpoint.Endpoint

MakeUpsertEndpoint returns an endpoint via the passed service.

Types

type Endpoints

type Endpoints struct {
	ReadEndpoint   endpoint.Endpoint
	ListEndpoint   endpoint.Endpoint
	UpsertEndpoint endpoint.Endpoint

	AddFollowerEndpoint    endpoint.Endpoint
	DeleteFollowerEndpoint endpoint.Endpoint
	ListFollowingsEndpoint endpoint.Endpoint
	ListFollowersEndpoint  endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, params auth.EndpointParams) Endpoints

MakeServerEndpoints returns an Endpoints struct where each endpoint invokes the corresponding method on the provided service. Useful in a profilesvc server.

type Filter

type Filter struct {
	LastName  string
	FirstName string
	IDs       []uuid.UUID
}

type HTTPHandlerParams

type HTTPHandlerParams struct {
	Logger *logrus.Entry
}

HTTPHandlerParams provides params for handlers service options.

type HTTPHandlerSet

type HTTPHandlerSet struct {
	UpsertProfileHandler http.Handler
	ReadProfileHandler   http.Handler
	ListProfileHandler   http.Handler

	ListFollowingsHandler http.Handler
	AddFollowerHandler    http.Handler
	DeleteFollowerHandler http.Handler

	ListFollowersHandler http.Handler
}

HTTPHandlerSet contains all service http handlers to register it in mux.router later.

func NewHTTPHandlerSet

func NewHTTPHandlerSet(endpoints Endpoints, params HTTPHandlerParams) HTTPHandlerSet

NewHTTPHandlerSet returns a http handler set for registration in the mux.Router later

func (*HTTPHandlerSet) Register

func (h *HTTPHandlerSet) Register(m *mux.Router)

Register add handlers to mux.Router with theirs paths.

type ListRequest

type ListRequest struct {
	FirstName string      `json:"-"`
	LastName  string      `json:"-"`
	Limit     int         `json:"-"`
	Offset    int64       `json:"-"`
	IDs       []uuid.UUID `json:"-"`
}

ListRequest collects the request parameters for the List method.

type ListResponse

type ListResponse struct {
	Profiles []domain.Profile `json:"data"`
	Err      error            `json:"err,omitempty"`
}

ListResponse collects the response parameters for the List method.

func (ListResponse) Failed

func (r ListResponse) Failed() error

Failed implements Failer.

type Publisher

type Publisher interface {
	PublishProfileFollowingCreatedEvent(ctx context.Context, profileID, followerID uuid.UUID) error
	PublishProfileFollowingDeletedEvent(ctx context.Context, profileID, followerID uuid.UUID) error
}

type PublisherImpl

type PublisherImpl struct {
	ProfileFollowingCreatedEventEndpoint endpoint.Endpoint
	ProfileFollowingDeletedEventEndpoint endpoint.Endpoint
}

func NewPublisher

func NewPublisher(
	channel *amqp.Channel,
	logger *logrus.Entry,
	retryBackoff backoff.BackOff,
) (*PublisherImpl, error)

func (PublisherImpl) PublishProfileFollowingCreatedEvent

func (publisher PublisherImpl) PublishProfileFollowingCreatedEvent(ctx context.Context, profileID, followerID uuid.UUID) error

func (PublisherImpl) PublishProfileFollowingDeletedEvent

func (publisher PublisherImpl) PublishProfileFollowingDeletedEvent(ctx context.Context, profileID, followerID uuid.UUID) error

type Repository

type Repository interface {
	FindByID(id uuid.UUID) (*domain.Profile, error)
	AddFollower(profileID, followerID uuid.UUID) error
	DeleteFollower(profileID, followerID uuid.UUID) error
	Insert(profile *domain.Profile) error
	Update(profile *domain.Profile) error
	FindAllWithFilter(offset int64, limit int, f Filter) ([]domain.Profile, error)
	FindFollowers(id uuid.UUID, offset int64, limit int) ([]domain.Profile, error)
	FindFollowings(id uuid.UUID) ([]domain.Profile, error)
	FindByIDs(ids []uuid.UUID) (map[uuid.UUID]domain.Profile, error)
}

type RepositoryImpl

type RepositoryImpl struct {
	// contains filtered or unexported fields
}

repository represent profile db profile Repository.

func NewProfileRepository

func NewProfileRepository(
	masterConn database.QueryerExecer,
	slaveConn database.Queryer,
) *RepositoryImpl

NewProfileRepository is constructor.

func (RepositoryImpl) AddFollower

func (r RepositoryImpl) AddFollower(profileID, followerID uuid.UUID) error

func (RepositoryImpl) DeleteFollower

func (r RepositoryImpl) DeleteFollower(profileID, followerID uuid.UUID) error

func (RepositoryImpl) FindAllWithFilter

func (r RepositoryImpl) FindAllWithFilter(offset int64, limit int, f Filter) ([]domain.Profile, error)

FindAllWithFilter finds profiles by Filter.

func (RepositoryImpl) FindByID

func (r RepositoryImpl) FindByID(id uuid.UUID) (profile *domain.Profile, err error)

FindByID finds profile by id.

func (RepositoryImpl) FindByIDs

func (r RepositoryImpl) FindByIDs(ids []uuid.UUID) (res map[uuid.UUID]domain.Profile, err error)

func (RepositoryImpl) FindFollowers

func (r RepositoryImpl) FindFollowers(id uuid.UUID, offset int64, limit int) ([]domain.Profile, error)

func (RepositoryImpl) FindFollowings

func (r RepositoryImpl) FindFollowings(id uuid.UUID) ([]domain.Profile, error)

func (RepositoryImpl) Insert

func (r RepositoryImpl) Insert(profile *domain.Profile) error

func (RepositoryImpl) Update

func (r RepositoryImpl) Update(profile *domain.Profile) error

type Service

type Service interface {
	List(ctx context.Context, limit int, offset int64, filter Filter) ([]domain.Profile, error)
	Upsert(ctx context.Context, id uuid.UUID, profile domain.Profile) (result *domain.Profile, err error)
	Read(ctx context.Context, id uuid.UUID) (result *domain.Profile, err error)
	AddFollower(ctx context.Context, id, followerID uuid.UUID) error
	RemoveFollower(ctx context.Context, id, followerID uuid.UUID) error
	ListFollowings(ctx context.Context, id uuid.UUID) ([]domain.Profile, error)
	ListFollowers(ctx context.Context, id uuid.UUID) ([]domain.Profile, error)
}

func NewService

func NewService(
	repository Repository,
	uuidGenerator uuid.Generator,
	publisher Publisher,
) Service

Jump to

Keyboard shortcuts

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