Documentation ¶
Index ¶
- Constants
- Variables
- type Budgerigar
- func (b *Budgerigar) All() []*Stub
- func (b *Budgerigar) Clear()
- func (b *Budgerigar) DeleteByID(ids ...uuid.UUID) int
- func (b *Budgerigar) FindBy(service, method string) ([]*Stub, error)
- func (b *Budgerigar) FindByID(id uuid.UUID) *Stub
- func (b *Budgerigar) FindByQuery(query Query) (*Result, error)
- func (b *Budgerigar) PutMany(values ...*Stub) []uuid.UUID
- func (b *Budgerigar) Unused() []*Stub
- func (b *Budgerigar) UpdateMany(values ...*Stub) []uuid.UUID
- func (b *Budgerigar) Used() []*Stub
- type InputData
- type InputHeader
- type Output
- type Query
- type Result
- type Stub
- type Value
Constants ¶
const MethodTitle features.Flag = iota
MethodTitle is a feature flag for using title casing in the method field of a Query struct.
const (
RequestInternalFlag features.Flag = iota
)
Variables ¶
var ErrLeftNotFound = errors.New("left not found")
ErrLeftNotFound is returned when the left value is not found.
var ErrMethodNotFound = errors.New("method not found")
ErrMethodNotFound is returned when the method is not found.
var ErrRightNotFound = errors.New("right not found")
ErrRightNotFound is returned when the right value is not found.
var ErrServiceNotFound = errors.New("service not found")
ErrServiceNotFound is returned when the service is not found.
var ErrStubNotFound = errors.New("stub not found")
ErrStubNotFound is returned when the stub is not found.
Functions ¶
This section is empty.
Types ¶
type Budgerigar ¶
type Budgerigar struct {
// contains filtered or unexported fields
}
Budgerigar is the main struct for the stuber package. It contains a searcher and toggles.
func NewBudgerigar ¶
func NewBudgerigar(toggles features.Toggles) *Budgerigar
NewBudgerigar creates a new Budgerigar with the given features.Toggles.
Parameters: - toggles: The features.Toggles to use.
Returns: - A new Budgerigar.
func (*Budgerigar) All ¶
func (b *Budgerigar) All() []*Stub
All returns all Stub values from the Budgerigar's searcher.
Returns: - []*Stub: All Stub values.
func (*Budgerigar) Clear ¶
func (b *Budgerigar) Clear()
Clear clears all Stub values from the Budgerigar's searcher.
func (*Budgerigar) DeleteByID ¶
func (b *Budgerigar) DeleteByID(ids ...uuid.UUID) int
DeleteByID deletes the Stub values with the given IDs from the Budgerigar's searcher.
Parameters: - ids: The UUIDs of the Stub values to delete.
Returns: - int: The number of Stub values that were successfully deleted.
func (*Budgerigar) FindBy ¶
func (b *Budgerigar) FindBy(service, method string) ([]*Stub, error)
FindBy retrieves all Stub values that match the given service and method from the Budgerigar's searcher.
Parameters: - service: The service field used to search for Stub values. - method: The method field used to search for Stub values.
Returns: - []*Stub: The Stub values that match the given service and method, or nil if not found. - error: An error if the search fails.
func (*Budgerigar) FindByID ¶
func (b *Budgerigar) FindByID(id uuid.UUID) *Stub
FindByID retrieves the Stub value associated with the given ID from the Budgerigar's searcher.
Parameters: - id: The UUID of the Stub value to retrieve.
Returns: - *Stub: The Stub value associated with the given ID, or nil if not found.
func (*Budgerigar) FindByQuery ¶
func (b *Budgerigar) FindByQuery(query Query) (*Result, error)
FindByQuery retrieves the Stub value associated with the given Query from the Budgerigar's searcher.
Parameters: - query: The Query used to search for a Stub value.
Returns: - *Result: The Result containing the found Stub value (if any), or nil. - error: An error if the search fails.
func (*Budgerigar) PutMany ¶
func (b *Budgerigar) PutMany(values ...*Stub) []uuid.UUID
PutMany inserts the given Stub values into the Budgerigar. If a Stub value does not have a key, a new UUID is generated for its key.
Parameters: - values: The Stub values to insert.
Returns: - []uuid.UUID: The keys of the inserted Stub values.
func (*Budgerigar) Unused ¶
func (b *Budgerigar) Unused() []*Stub
Unused returns all Stub values that have not been used from the Budgerigar's searcher.
Returns: - []*Stub: All unused Stub values.
func (*Budgerigar) UpdateMany ¶ added in v1.0.1
func (b *Budgerigar) UpdateMany(values ...*Stub) []uuid.UUID
func (*Budgerigar) Used ¶
func (b *Budgerigar) Used() []*Stub
Used returns all Stub values that have been used from the Budgerigar's searcher.
Returns: - []*Stub: All used Stub values.
type InputData ¶
type InputData struct { IgnoreArrayOrder bool `json:"ignoreArrayOrder,omitempty"` // Whether to ignore the order of arrays in the input data. Equals map[string]interface{} `json:"equals"` // The data to match exactly. Contains map[string]interface{} `json:"contains"` // The data to match partially. Matches map[string]interface{} `json:"matches"` // The data to match using regular expressions. }
InputData represents the input data of a gRPC request.
func (InputData) GetContains ¶
GetContains returns the data to match partially.
func (InputData) GetMatches ¶
GetMatches returns the data to match using regular expressions.
type InputHeader ¶
type InputHeader struct { Equals map[string]interface{} `json:"equals"` // The headers to match exactly. Contains map[string]interface{} `json:"contains"` // The headers to match partially. Matches map[string]interface{} `json:"matches"` // The headers to match using regular expressions. }
InputHeader represents the headers of a gRPC request.
func (InputHeader) GetContains ¶
func (i InputHeader) GetContains() map[string]interface{}
GetContains returns the headers to match partially.
func (InputHeader) GetEquals ¶
func (i InputHeader) GetEquals() map[string]interface{}
GetEquals returns the headers to match exactly.
func (InputHeader) GetMatches ¶
func (i InputHeader) GetMatches() map[string]interface{}
GetMatches returns the headers to match using regular expressions.
func (InputHeader) Len ¶
func (i InputHeader) Len() int
Len returns the total number of headers to match.
type Output ¶
type Output struct { Headers map[string]string `json:"headers"` // The headers of the response. Data map[string]interface{} `json:"data"` // The data of the response. Error string `json:"error"` // The error message of the response. Code *codes.Code `json:"code,omitempty"` // The status code of the response. }
Output represents the output data of a gRPC response.
type Query ¶
type Query struct { ID *uuid.UUID `json:"id,omitempty"` Service string `json:"service"` Method string `json:"method"` Headers map[string]interface{} `json:"headers"` Data map[string]interface{} `json:"data"` // contains filtered or unexported fields }
func (Query) RequestInternal ¶
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result represents the result of a search operation.
It contains two fields: found and similar. Found represents the exact match found in the search, while similar represents the most similar match found.
type Stub ¶
type Stub struct { ID uuid.UUID `json:"id"` // The unique identifier of the stub. Service string `json:"service"` // The name of the service. Method string `json:"method"` // The name of the method. Headers InputHeader `json:"headers"` // The headers of the request. Input InputData `json:"input"` // The input data of the request. Output Output `json:"output"` // The output data of the response. }
Stub represents a gRPC service method and its associated data.
type Value ¶
type Value interface { Key() uuid.UUID // The UUID of the value. Left() string // The left value of the value. Right() string // The right value of the value. }
Value is a type used to store the result of a search.
This interface is used to represent the search results returned by the Find and Search methods.