Documentation ¶
Overview ¶
Package observations handle the request of observations data from governor endpoint defined in the api.
Package observations handle the request of observations data from governor endpoint defined in the api.
Package observations handle the request of observations data from governor endpoint defined in the api.
Index ¶
- type ObservationDoc
- type ObservationQuery
- func (q *ObservationQuery) SetChain(chainID vaa.ChainID) *ObservationQuery
- func (q *ObservationQuery) SetEmitter(emitter string) *ObservationQuery
- func (q *ObservationQuery) SetHash(hash []byte) *ObservationQuery
- func (q *ObservationQuery) SetPagination(p *pagination.Pagination) *ObservationQuery
- func (q *ObservationQuery) SetPhylaxAddr(phylaxAddr string) *ObservationQuery
- func (q *ObservationQuery) SetSequence(seq string) *ObservationQuery
- type Repository
- type Service
- func (s *Service) FindAll(ctx context.Context, p *pagination.Pagination) ([]*ObservationDoc, error)
- func (s *Service) FindByChain(ctx context.Context, chain vaa.ChainID, p *pagination.Pagination) ([]*ObservationDoc, error)
- func (s *Service) FindByEmitter(ctx context.Context, chain vaa.ChainID, emitter *types.Address, ...) ([]*ObservationDoc, error)
- func (s *Service) FindByVAA(ctx context.Context, chain vaa.ChainID, emitter *types.Address, seq string, ...) ([]*ObservationDoc, error)
- func (s *Service) FindOne(ctx context.Context, chainID vaa.ChainID, emitterAddr *types.Address, ...) (*ObservationDoc, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObservationDoc ¶
type ObservationDoc struct { ID string `bson:"_id" json:"id"` EmitterChain vaa.ChainID `bson:"emitterChain" json:"emitterChain"` EmitterAddr string `bson:"emitterAddr" json:"emitterAddr"` Sequence string `bson:"sequence" json:"sequence"` Hash []byte `bson:"hash" json:"hash"` TxHash []byte `bson:"txHash" json:"txHash"` PhylaxAddr string `bson:"phylaxAddr" json:"phylaxAddr"` Signature []byte `bson:"signature" json:"signature"` UpdatedAt *time.Time `bson:"updatedAt" json:"updatedAt"` IndexedAt *time.Time `bson:"indexedAt" json:"indexedAt"` }
ObservationDoc represent an observation document.
func (*ObservationDoc) MarshalJSON ¶
func (o *ObservationDoc) MarshalJSON() ([]byte, error)
MarshalJSON interface implementation for ObservationDoc.
type ObservationQuery ¶
type ObservationQuery struct { pagination.Pagination // contains filtered or unexported fields }
ObservationQuery respresent a query for the observation mongodb document.
func Query ¶
func Query() *ObservationQuery
Query create a new ObservationQuery with default pagination vaues.
func (*ObservationQuery) SetChain ¶
func (q *ObservationQuery) SetChain(chainID vaa.ChainID) *ObservationQuery
SetEmitter set the chainId field of the ObservationQuery struct.
func (*ObservationQuery) SetEmitter ¶
func (q *ObservationQuery) SetEmitter(emitter string) *ObservationQuery
SetEmitter set the emitter field of the ObservationQuery struct.
func (*ObservationQuery) SetHash ¶
func (q *ObservationQuery) SetHash(hash []byte) *ObservationQuery
SetHash set the hash field of the ObservationQuery struct.
func (*ObservationQuery) SetPagination ¶
func (q *ObservationQuery) SetPagination(p *pagination.Pagination) *ObservationQuery
SetPagination set the pagination field of the ObservationQuery struct.
func (*ObservationQuery) SetPhylaxAddr ¶
func (q *ObservationQuery) SetPhylaxAddr(phylaxAddr string) *ObservationQuery
SetPhylaxAddr set the phylaxAddr field of the ObservationQuery struct.
func (*ObservationQuery) SetSequence ¶
func (q *ObservationQuery) SetSequence(seq string) *ObservationQuery
SetSequence set the sequence field of the ObservationQuery struct.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository definition.
func NewRepository ¶
func NewRepository(db *mongo.Database, logger *zap.Logger) *Repository
NewRepository create a new Repository.
func (*Repository) Find ¶
func (r *Repository) Find(ctx context.Context, q *ObservationQuery) ([]*ObservationDoc, error)
Find get a list of ObservationDoc pointers. The input parameter [q *ObservationQuery] define the filters to apply in the query.
func (*Repository) FindOne ¶
func (r *Repository) FindOne(ctx context.Context, q *ObservationQuery) (*ObservationDoc, error)
Find get ObservationDoc pointer. The input parameter [q *ObservationQuery] define the filters to apply in the query.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service definition.
func NewService ¶
func NewService(dao *Repository, logger *zap.Logger) *Service
NewService create a new Service.
func (*Service) FindAll ¶
func (s *Service) FindAll(ctx context.Context, p *pagination.Pagination) ([]*ObservationDoc, error)
FindAll get all the observations.
func (*Service) FindByChain ¶
func (s *Service) FindByChain(ctx context.Context, chain vaa.ChainID, p *pagination.Pagination) ([]*ObservationDoc, error)
FindByChain get all the observations by chainID.
func (*Service) FindByEmitter ¶
func (s *Service) FindByEmitter( ctx context.Context, chain vaa.ChainID, emitter *types.Address, p *pagination.Pagination, ) ([]*ObservationDoc, error)
FindByEmitter get all the observations by chainID and emitter address.
func (*Service) FindByVAA ¶
func (s *Service) FindByVAA( ctx context.Context, chain vaa.ChainID, emitter *types.Address, seq string, p *pagination.Pagination, ) ([]*ObservationDoc, error)
FindByVAA get all the observations for a VAA (chainID, emitter addrress and sequence number).