Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Defining the Indexer interface

Similar to the approach we followed when we modeled the link graph component, we shall encapsulate the preceding list of operations into a Go interface called Indexer:

type Indexer interface {
    Index(doc *Document) error
    FindByID(linkID uuid.UUID) (*Document, error)
    Search(query Query) (Iterator, error)
    UpdateScore(linkID uuid.UUID, score float64) error
}

The Search method expects a Query type instead of a simple string value as its input argument. This is by design; it offers us the flexibility to expand the indexer's query capabilities further down the road to support richer query semantics without having to modify the signature of the Search method. Here is the definition of the Query type:

type Query 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content