Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) CreateSync(ctx context.Context, remoteURL string, cids []string) (string, error)
- func (c *Client) Delete(ctx context.Context, recordRef *corev1.RecordRef) error
- func (c *Client) DeleteBatch(ctx context.Context, recordRefs []*corev1.RecordRef) error
- func (c *Client) DeleteStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[emptypb.Empty], error)
- func (c *Client) DeleteSync(ctx context.Context, syncID string) error
- func (c *Client) GetSync(ctx context.Context, syncID string) (*storev1.GetSyncResponse, error)
- func (c *Client) List(ctx context.Context, req *routingv1.ListRequest) (<-chan *routingv1.ListResponse, error)
- func (c *Client) ListSyncs(ctx context.Context, req *storev1.ListSyncsRequest) (<-chan *storev1.ListSyncsItem, error)
- func (c *Client) ListenStream(ctx context.Context, req *eventsv1.ListenRequest) (streaming.StreamResult[eventsv1.ListenResponse], error)
- func (c *Client) Lookup(ctx context.Context, recordRef *corev1.RecordRef) (*corev1.RecordMeta, error)
- func (c *Client) LookupBatch(ctx context.Context, recordRefs []*corev1.RecordRef) ([]*corev1.RecordMeta, error)
- func (c *Client) LookupStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[corev1.RecordMeta], error)
- func (c *Client) Publish(ctx context.Context, req *routingv1.PublishRequest) error
- func (c *Client) Pull(ctx context.Context, recordRef *corev1.RecordRef) (*corev1.Record, error)
- func (c *Client) PullBatch(ctx context.Context, recordRefs []*corev1.RecordRef) ([]*corev1.Record, error)
- func (c *Client) PullReferrer(ctx context.Context, req *storev1.PullReferrerRequest) (<-chan *storev1.PullReferrerResponse, error)
- func (c *Client) PullStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[corev1.Record], error)
- func (c *Client) Push(ctx context.Context, record *corev1.Record) (*corev1.RecordRef, error)
- func (c *Client) PushBatch(ctx context.Context, records []*corev1.Record) ([]*corev1.RecordRef, error)
- func (c *Client) PushReferrer(ctx context.Context, req *storev1.PushReferrerRequest) error
- func (c *Client) PushStream(ctx context.Context, recordsCh <-chan *corev1.Record) (streaming.StreamResult[corev1.RecordRef], error)
- func (c *Client) SearchCIDs(ctx context.Context, req *searchv1.SearchCIDsRequest) (streaming.StreamResult[searchv1.SearchCIDsResponse], error)
- func (c *Client) SearchRecords(ctx context.Context, req *searchv1.SearchRecordsRequest) (streaming.StreamResult[searchv1.SearchRecordsResponse], error)
- func (c *Client) SearchRouting(ctx context.Context, req *routingv1.SearchRequest) (<-chan *routingv1.SearchResponse, error)
- func (c *Client) Sign(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
- func (c *Client) SignWithKey(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
- func (c *Client) SignWithOIDC(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
- func (c *Client) Unpublish(ctx context.Context, req *routingv1.UnpublishRequest) error
- func (c *Client) Verify(ctx context.Context, req *signv1.VerifyRequest) (*signv1.VerifyResponse, error)
- type Config
- type Option
- type SignOpts
Constants ¶
const ( DefaultEnvPrefix = "DIRECTORY_CLIENT" DefaultServerAddress = "0.0.0.0:8888" DefaultTlsSkipVerify = false )
Variables ¶
var DefaultConfig = Config{ ServerAddress: DefaultServerAddress, }
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
storev1.StoreServiceClient
routingv1.RoutingServiceClient
searchv1.SearchServiceClient
storev1.SyncServiceClient
signv1.SignServiceClient
eventsv1.EventServiceClient
// contains filtered or unexported fields
}
func (*Client) CreateSync ¶
func (*Client) DeleteBatch ¶
DeleteBatch removes multiple records from the store in a single stream for efficiency.
func (*Client) DeleteStream ¶
func (c *Client) DeleteStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[emptypb.Empty], error)
DeleteStream provides efficient streaming delete operations using channels. Record references are sent as they become available and delete confirmations are returned as they're processed. This method maintains a single gRPC stream for all operations, dramatically improving efficiency.
func (*Client) List ¶
func (c *Client) List(ctx context.Context, req *routingv1.ListRequest) (<-chan *routingv1.ListResponse, error)
func (*Client) ListSyncs ¶
func (c *Client) ListSyncs(ctx context.Context, req *storev1.ListSyncsRequest) (<-chan *storev1.ListSyncsItem, error)
func (*Client) ListenStream ¶
func (c *Client) ListenStream(ctx context.Context, req *eventsv1.ListenRequest) (streaming.StreamResult[eventsv1.ListenResponse], error)
ListenStream streams events from the server with the specified filters.
Returns a StreamResult that provides structured channels for receiving events, errors, and completion signals.
Example - Listen to all events:
result, err := client.ListenStream(ctx, &eventsv1.ListenRequest{})
if err != nil {
return err
}
for {
select {
case resp := <-result.ResCh():
event := resp.GetEvent()
fmt.Printf("Event: %s - %s\n", event.Type, event.ResourceId)
case err := <-result.ErrCh():
return fmt.Errorf("stream error: %w", err)
case <-result.DoneCh():
return nil
case <-ctx.Done():
return ctx.Err()
}
}
Example - Filter by event type:
result, err := client.ListenStream(ctx, &eventsv1.ListenRequest{
EventTypes: []eventsv1.EventType{
eventsv1.EventType_EVENT_TYPE_RECORD_PUSHED,
eventsv1.EventType_EVENT_TYPE_RECORD_PUBLISHED,
},
})
Example - Filter by labels:
result, err := client.ListenStream(ctx, &eventsv1.ListenRequest{
LabelFilters: []string{"/skills/AI"},
})
func (*Client) Lookup ¶
func (c *Client) Lookup(ctx context.Context, recordRef *corev1.RecordRef) (*corev1.RecordMeta, error)
Lookup retrieves metadata for a record using its reference.
func (*Client) LookupBatch ¶
func (c *Client) LookupBatch(ctx context.Context, recordRefs []*corev1.RecordRef) ([]*corev1.RecordMeta, error)
LookupBatch retrieves metadata for multiple records in a single stream for efficiency.
func (*Client) LookupStream ¶
func (c *Client) LookupStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[corev1.RecordMeta], error)
LookupStream provides efficient streaming lookup operations using channels. Record references are sent as they become available and metadata is returned as it's processed. This method maintains a single gRPC stream for all operations, dramatically improving efficiency.
Uses sequential streaming pattern (Send → Recv → Send → Recv) which ensures strict ordering of request-response pairs.
func (*Client) Pull ¶
Pull retrieves a single record from the store using its reference. This is a convenience wrapper around PullBatch for single-record operations.
func (*Client) PullBatch ¶
func (c *Client) PullBatch(ctx context.Context, recordRefs []*corev1.RecordRef) ([]*corev1.Record, error)
PullBatch retrieves multiple records in a single stream for efficiency. This is a convenience method that accepts a slice and returns a slice, built on top of the streaming implementation for consistency.
func (*Client) PullReferrer ¶
func (c *Client) PullReferrer(ctx context.Context, req *storev1.PullReferrerRequest) (<-chan *storev1.PullReferrerResponse, error)
PullReferrer retrieves all referrers using the PullReferrer RPC.
func (*Client) PullStream ¶
func (c *Client) PullStream(ctx context.Context, refsCh <-chan *corev1.RecordRef) (streaming.StreamResult[corev1.Record], error)
PullStream retrieves multiple records efficiently using a single bidirectional stream. This method is ideal for batch operations and takes full advantage of gRPC streaming. The input channel allows you to send record refs as they become available.
func (*Client) Push ¶
Push sends a complete record to the store and returns a record reference. This is a convenience wrapper around PushBatch for single-record operations. The record must be ≤4MB as per the v1 store service specification.
func (*Client) PushBatch ¶
func (c *Client) PushBatch(ctx context.Context, records []*corev1.Record) ([]*corev1.RecordRef, error)
PushBatch sends multiple records in a single stream for efficiency. This is a convenience method that accepts a slice and returns a slice, built on top of the streaming implementation for consistency.
func (*Client) PushReferrer ¶
PushReferrer stores a signature using the PushReferrer RPC.
func (*Client) PushStream ¶
func (c *Client) PushStream(ctx context.Context, recordsCh <-chan *corev1.Record) (streaming.StreamResult[corev1.RecordRef], error)
PushStream uploads multiple records efficiently using a single bidirectional stream. This method is ideal for batch operations and takes full advantage of gRPC streaming. The input channel allows you to send records as they become available.
func (*Client) SearchCIDs ¶ added in v0.5.6
func (c *Client) SearchCIDs(ctx context.Context, req *searchv1.SearchCIDsRequest) (streaming.StreamResult[searchv1.SearchCIDsResponse], error)
SearchCIDs searches for record CIDs matching the given request.
func (*Client) SearchRecords ¶ added in v0.5.6
func (c *Client) SearchRecords(ctx context.Context, req *searchv1.SearchRecordsRequest) (streaming.StreamResult[searchv1.SearchRecordsResponse], error)
SearchRecords searches for full records matching the given request.
func (*Client) SearchRouting ¶
func (c *Client) SearchRouting(ctx context.Context, req *routingv1.SearchRequest) (<-chan *routingv1.SearchResponse, error)
func (*Client) Sign ¶
func (c *Client) Sign(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
Sign routes to the appropriate signing method based on provider type. This is the main entry point for signing operations.
func (*Client) SignWithKey ¶
func (c *Client) SignWithKey(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
func (*Client) SignWithOIDC ¶
func (c *Client) SignWithOIDC(ctx context.Context, req *signv1.SignRequest) (*signv1.SignResponse, error)
SignWithOIDC signs the record using keyless OIDC service-based signing. The OIDC ID Token can be provided by the caller, or cosign will handle interactive OIDC flow. This implementation uses cosign sign-blob command for OIDC signing.
func (*Client) Verify ¶
func (c *Client) Verify(ctx context.Context, req *signv1.VerifyRequest) (*signv1.VerifyResponse, error)
Verify verifies the signature of the record.
type Config ¶
type Config struct {
ServerAddress string `json:"server_address,omitempty" mapstructure:"server_address"`
TlsSkipVerify bool `json:"tls_skip_verify,omitempty" mapstructure:"tls_skip_verify"`
TlsCertFile string `json:"tls_cert_file,omitempty" mapstructure:"tls_cert_file"`
TlsKeyFile string `json:"tls_key_file,omitempty" mapstructure:"tls_key_file"`
TlsCAFile string `json:"tls_ca_file,omitempty" mapstructure:"tls_ca_file"`
SpiffeSocketPath string `json:"spiffe_socket_path,omitempty" mapstructure:"spiffe_socket_path"`
SpiffeToken string `json:"spiffe_token,omitempty" mapstructure:"spiffe_token"`
AuthMode string `json:"auth_mode,omitempty" mapstructure:"auth_mode"`
JWTAudience string `json:"jwt_audience,omitempty" mapstructure:"jwt_audience"`
}
func LoadConfig ¶
type Option ¶
type Option func(*options) error
func WithConfig ¶
func WithEnvConfig ¶
func WithEnvConfig() Option