Documentation
¶
Index ¶
- Constants
- Variables
- type ApiClient
- type ApiClientArgs
- type AtKafkaAccount
- type AtKafkaEvent
- type AtKafkaIdentity
- type AtKafkaInfo
- type AtKafkaOp
- type DidAuditEntry
- type DidAuditLog
- type DidLogEntry
- type EventMetadata
- type IdentityResolver
- type IdentityResolverArgs
- type OperationService
- type OspreyAtKafkaEvent
- type OspreyEventData
- type OzoneClient
- type OzoneClientArgs
- type OzoneServer
- type OzoneServerArgs
- type Producer
- type ProducerOption
- func WithClient(client *kgo.Client) ProducerOption
- func WithCredentials(username, password string) ProducerOption
- func WithEnsureTopic(ensure bool) ProducerOption
- func WithHostOverride(host string) ProducerOption
- func WithInfiniteRetention() ProducerOption
- func WithMaxMessageBytes(bytes int) ProducerOption
- func WithReplicationFactor(replicationFactor int) ProducerOption
- func WithRetentionBytes(bytes int) ProducerOption
- func WithRetentionTime(duration time.Duration) ProducerOption
- func WithTopicConfig(config ...string) ProducerOption
- func WithTopicPartitions(partitions int) ProducerOption
- type Server
- type ServerArgs
- type TapAck
- type TapEvent
- type TapEventIdentity
- type TapEventRecord
Constants ¶
const ( DefaultClientID = "go-bus-producer" ModeAsync = "async" ModeSync = "sync" )
const (
DefaultPLCHost = "https://plc.directory"
)
Variables ¶
var ErrAuditLogNotFound = errors.New("audit log not found for DID")
Functions ¶
This section is empty.
Types ¶
type ApiClient ¶ added in v0.1.1
type ApiClient struct {
// contains filtered or unexported fields
}
func NewApiClient ¶ added in v0.1.1
func NewApiClient(args *ApiClientArgs) (*ApiClient, error)
func (*ApiClient) BustProfileCache ¶ added in v0.1.1
func (*ApiClient) GetProfile ¶ added in v0.1.1
type ApiClientArgs ¶ added in v0.1.1
type ApiClientArgs struct {
ApiHost string
}
type AtKafkaAccount ¶
type AtKafkaEvent ¶
type AtKafkaEvent struct {
Did string `json:"did"`
Timestamp string `json:"timestamp"`
Metadata *EventMetadata `json:"eventMetadata"`
Operation *AtKafkaOp `json:"operation,omitempty"`
Account *AtKafkaAccount `json:"account,omitempty"`
Identity *AtKafkaIdentity `json:"identity,omitempty"`
Info *AtKafkaInfo `json:"info,omitempty"`
}
type AtKafkaIdentity ¶
type AtKafkaInfo ¶
type DidAuditEntry ¶
type DidAuditEntry struct {
Did string `json:"did"`
Operation DidLogEntry `json:"operation"`
Cid string `json:"cid"`
Nullified bool `json:"nullified"`
CreatedAt string `json:"createdAt"`
}
type DidAuditLog ¶
type DidAuditLog []DidAuditEntry
type DidLogEntry ¶
type DidLogEntry struct {
Sig string `json:"sig"`
Prev *string `json:"prev"`
Type string `json:"type"`
Services map[string]OperationService `json:"services"`
AlsoKnownAs []string `json:"alsoKnownAs"`
RotationKeys []string `json:"rotationKeys"`
VerificationMethods map[string]string `json:"verificationMethods"`
}
type EventMetadata ¶
type EventMetadata struct {
DidDocument identity.DIDDocument `json:"didDocument,omitempty"`
PdsHost string `json:"pdsHost,omitempty"`
Handle string `json:"handle,omitempty"`
DidCreatedAt string `json:"didCreatedAt,omitempty"`
AccountAge int64 `json:"accountAge"`
Profile *bsky.ActorDefs_ProfileViewDetailed `json:"profile"`
}
type IdentityResolver ¶ added in v0.2.1
type IdentityResolver struct {
// contains filtered or unexported fields
}
func NewIdentityResolver ¶ added in v0.2.1
func NewIdentityResolver(args *IdentityResolverArgs) *IdentityResolver
func (*IdentityResolver) GetDIDAuditLog ¶ added in v0.2.1
func (c *IdentityResolver) GetDIDAuditLog(ctx context.Context, did syntax.DID) (*DidAuditEntry, error)
func (*IdentityResolver) GetIdentity ¶ added in v0.2.1
type IdentityResolverArgs ¶ added in v0.2.1
type IdentityResolverArgs struct {
PlcHost string
}
type OperationService ¶
type OspreyAtKafkaEvent ¶
type OspreyAtKafkaEvent struct {
Data OspreyEventData `json:"data"`
SendTime string `json:"send_time"`
}
type OspreyEventData ¶
type OspreyEventData struct {
ActionName string `json:"action_name"`
ActionId int64 `json:"action_id"`
Data AtKafkaEvent `json:"data"`
Timestamp string `json:"timestamp"`
SecretData map[string]string `json:"secret_data"`
Encoding string `json:"encoding"`
}
Intentionally using snake case since that is what Osprey expects
type OzoneClient ¶ added in v0.2.0
type OzoneClient struct {
// contains filtered or unexported fields
}
func NewOzoneClient ¶ added in v0.2.0
func NewOzoneClient(args *OzoneClientArgs) (*OzoneClient, error)
func (*OzoneClient) GetEvents ¶ added in v0.2.0
func (oc *OzoneClient) GetEvents(ctx context.Context, before string) (*string, []*ozone.ModerationDefs_ModEventView, error)
type OzoneClientArgs ¶ added in v0.2.0
type OzoneServer ¶ added in v0.2.0
type OzoneServer struct {
// contains filtered or unexported fields
}
func NewOzoneServer ¶ added in v0.2.0
func NewOzoneServer(args *OzoneServerArgs) (*OzoneServer, error)
func (*OzoneServer) GetCursor ¶ added in v0.2.0
func (s *OzoneServer) GetCursor() string
func (*OzoneServer) LoadCursor ¶ added in v0.2.0
func (s *OzoneServer) LoadCursor() error
func (*OzoneServer) UpdateCursor ¶ added in v0.2.0
func (s *OzoneServer) UpdateCursor(cursor string) error
type OzoneServerArgs ¶ added in v0.2.0
type OzoneServerArgs struct {
BootstrapServers []string
OutputTopic string
Logger *slog.Logger
OzoneClientArgs *OzoneClientArgs
}
type Producer ¶
type Producer struct {
// Close the producer and flush any async writes.
// We can safely call this concurrently and multiple times, as it uses a sync.Once to ensure the client is only flushed and closed once.
Close func()
// contains filtered or unexported fields
}
Producer is an example producer to a given topic using given Protobuf message type.
A Producer takes a Kafka client and a topic, and sends one of two types of data:
- A Protobuf message of the given type.
- Invalid data that could not be parsed as any Protobuf message.
func NewProducer ¶
func NewProducer( ctx context.Context, logger *slog.Logger, bootstrapServers []string, topic string, options ...ProducerOption, ) (*Producer, error)
New returns a new Producer.
Always use this constructor to construct Producers.
func (*Producer) ProduceAsync ¶
func (p *Producer) ProduceAsync(ctx context.Context, key string, message []byte, cb func(r *kgo.Record, err error)) error
ProduceAsync asynchronously sends the given message to the Producer's topic with the given partition key. This should return immediately, and the message will be sent in the background. Errors returned from this method are only related to serialization issues.
func (*Producer) ProduceSync ¶
ProduceSync serializes the given Protobuf messages, and synchronously sends it to the Producer's topic with the given partition key. This will block until the message is sent or an error occurs.
type ProducerOption ¶
type ProducerOption func(*Producer)
ProducerOption is an option when constructing a new Producer.
All parameters except options are required. ProducerOptions allow for optional parameters.
func WithClient ¶
func WithClient(client *kgo.Client) ProducerOption
WithClient allows initializing the producer with the specified Kafka client. This overrides the provided topic configuration and partitions.
func WithCredentials ¶
func WithCredentials(username, password string) ProducerOption
WithCredentials sets the SASL username and password for the producer.
func WithEnsureTopic ¶
func WithEnsureTopic(ensure bool) ProducerOption
WithEnsureTopic allows setting whether to ensure the topic exists before producing messages. If true, the producer will attempt to create the topic if it does not exist.
func WithHostOverride ¶
func WithHostOverride(host string) ProducerOption
WithHostOverride returns a new Producer Option that overrides the default broker host This allows us to connect to the Kafka broker using a different hostname than what the broker advertises.
func WithInfiniteRetention ¶
func WithInfiniteRetention() ProducerOption
WithInfiniteRetention allows setting the topic to have infinite retention time. By default Topics have a retention time of 7 days and infinite retention bytes.
func WithMaxMessageBytes ¶
func WithMaxMessageBytes(bytes int) ProducerOption
WithMaxMessageBytes allows setting the maximum message size for the topic. Default is 1MB (1048576 bytes).
func WithReplicationFactor ¶
func WithReplicationFactor(replicationFactor int) ProducerOption
WithReplicationFactor allows setting the replication factor for the topic.
func WithRetentionBytes ¶
func WithRetentionBytes(bytes int) ProducerOption
WithRetentionBytes allows setting the retention bytes for the topic.
func WithRetentionTime ¶
func WithRetentionTime(duration time.Duration) ProducerOption
WithRetentionTime allows setting the retention time for the topic (to millisecond precision).
func WithTopicConfig ¶
func WithTopicConfig(config ...string) ProducerOption
WithTopicConfig allows setting topic configuration options for the producer.
func WithTopicPartitions ¶
func WithTopicPartitions(partitions int) ProducerOption
WithTopicPartitions allows setting the number of partitions for the topic.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(args *ServerArgs) (*Server, error)
func (*Server) FetchEventMetadata ¶
type ServerArgs ¶
type ServerArgs struct {
// network params
RelayHost string
TapHost string
TapWorkers int
DisableAcks bool
PlcHost string
ApiHost string
// list of services that are events will be emitted for
WatchedServices []string
// list of services that events are ignored for
IgnoredServices []string
// list of collections that events are emitted for
WatchedCollections []string
// list of collections that events are ignored for
IgnoredCollections []string
// kafka params
BootstrapServers []string
OutputTopic string
// osprey-specific params
OspreyCompat bool
// other
Logger *slog.Logger
}
type TapEvent ¶ added in v0.2.0
type TapEvent struct {
Id uint `json:"id"`
Type string `json:"type"`
Record *TapEventRecord `json:"record,omitempty"`
Identity *TapEventIdentity `json:"identity,omitempty"`
}