directory

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 16 Imported by: 0

README

ODP directory package

Package directory searches the one canonical ODP directory for candidate Services. It does not search Service catalogs. After discovery, an Agent inspects each result's live ODP document and queries that Service's Collections and Offerings.

The production origin is fixed at https://api.inflowpay.ai. Select Sandbox to use the fixed https://sandbox.inflowpay.ai environment. Callers cannot configure another origin.

Search Services

SearchServices lazily traverses directory pages and yields validated Service summaries. Filters are structured and work without natural-language interpretation.

directoryClient, err := directory.New(directory.Options{})
if err != nil {
	return err
}

request := directory.SearchRequest{
	Query: "compute",
	Filters: &directory.ServiceFilters{
		Keywords: []string{"gpu", "accelerator"},
		Payments: []directory.PaymentFilter{{
			Name: odp.ProtocolMPP,
			Options: []odp.PaymentOption{odp.PaymentOptionInflow, odp.PaymentOptionSolana},
		}},
	},
	Limit: 25,
}

for candidate, err := range directoryClient.SearchServices(ctx, request, directory.IterationOptions{}) {
	if err != nil {
		return err
	}
	fmt.Printf("%s: %s\n", candidate.Name, candidate.ServiceOrigin)
}

Options within one payment filter are alternatives. The example matches Services that accept either InFlow or Solana through MPP. A protocol-only PaymentFilter{Name: odp.ProtocolMPP} matches any Service that advertises MPP. Facets.Payments reports protocol counts and Facets.PaymentOptions reports each protocol-option count independently.

Use SearchPages when facet counts or page-level additive members are needed:

for page, err := range directoryClient.SearchPages(ctx, request, directory.IterationOptions{}) {
	if err != nil {
		return err
	}
	consume(page.Items, page.Facets)
}

Opaque continuation links are followed with GET on the selected canonical origin. Traversal is limited to 16 pages by default and at most 10,000 results when MaxItems is configured. Stopping iteration stops network activity.

Suggestions

Suggestions help an Agent discover keyword vocabulary without downloading a global keyword list.

suggestions, err := directoryClient.SuggestServices(ctx, directory.SuggestionRequest{
	Prefix: "gp",
	Limit:  5,
})

Sandbox

directoryClient, err := directory.New(directory.Options{
	Environment: directory.Sandbox,
})

Options.HTTPClient permits transport policy and test injection while preserving the selected canonical origin. The client accepts up to five same-origin redirects, bounds response bodies, and returns non-success responses as *directory.RequestError with the status and response headers.

Documentation

Overview

Package directory provides the canonical ODP Service directory client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(options Options) (*Client, error)

func (*Client) Environment

func (client *Client) Environment() Environment

func (*Client) SearchPages

func (client *Client) SearchPages(ctx context.Context, request SearchRequest, options IterationOptions) iter.Seq2[SearchPage, error]

func (*Client) SearchServices

func (client *Client) SearchServices(ctx context.Context, request SearchRequest, options IterationOptions) iter.Seq2[Service, error]

func (*Client) SuggestServices

func (client *Client) SuggestServices(ctx context.Context, request SuggestionRequest) ([]string, error)

type Environment

type Environment string
const (
	Production Environment = "production"
	Sandbox    Environment = "sandbox"
)

type Facet

type Facet[Value any] struct {
	Count int64
	Value Value
}

type Facets

type Facets struct {
	Enrollment     []Facet[odp.EnrollmentProtocol]
	Keywords       []Facet[string]
	Operations     []Facet[odp.OperationDescriptor]
	PaymentOptions []Facet[PaymentOptionFacetValue]
	Payments       []Facet[odp.PaymentProtocol]
}

type IterationOptions

type IterationOptions struct {
	MaxItems int
	MaxPages int
}

type OperationFilter added in v0.2.0

type OperationFilter struct {
	Authentication odp.AuthenticationRequirement `json:"authentication,omitempty"`
	Name           odp.Operation                 `json:"name"`
}

type Options

type Options struct {
	Environment Environment
	HTTPClient  *http.Client
}

type PaymentFilter added in v0.2.0

type PaymentFilter struct {
	Authentication odp.AuthenticationRequirement `json:"authentication,omitempty"`
	Name           odp.Protocol                  `json:"name"`
	Options        []odp.PaymentOption           `json:"options,omitempty"`
}

type PaymentOptionFacetValue added in v0.3.2

type PaymentOptionFacetValue struct {
	Name   odp.Protocol      `json:"name"`
	Option odp.PaymentOption `json:"option"`
}

type RequestError

type RequestError struct {
	Header  http.Header
	Message string
	Status  int
}

func (*RequestError) Error

func (err *RequestError) Error() string

type SearchPage

type SearchPage struct {
	Additional odp.AdditionalMembers
	Facets     *Facets
	Items      []Service
	Next       string
}

type SearchRequest

type SearchRequest struct {
	Filters *ServiceFilters `json:"filters,omitempty"`
	Limit   int             `json:"limit,omitempty"`
	Query   string          `json:"query,omitempty"`
}

type Service

type Service struct {
	Additional    odp.AdditionalMembers
	Description   string
	IndexedAt     time.Time
	Keywords      []string
	Language      string
	Localizations []string
	Name          string
	Operations    []odp.OperationDescriptor
	Protocols     *odp.ServiceProtocols
	ServiceOrigin string
}

type ServiceFilters

type ServiceFilters struct {
	Enrollment []odp.EnrollmentProtocol `json:"enrollment,omitempty"`
	Keywords   []string                 `json:"keywords,omitempty"`
	Operations []OperationFilter        `json:"operations,omitempty"`
	Payments   []PaymentFilter          `json:"payments,omitempty"`
}

type SuggestionRequest

type SuggestionRequest struct {
	Limit  int
	Prefix string
}

Jump to

Keyboard shortcuts

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