Documentation ¶
Overview ¶
Package server implements an ATproto labeler, using [bbolt](https://github.com/etcd-io/bbolt) as storage.
Example usage:
server, err := server.New(ctx, config.DBFile, config.DID, key) if err != nil { return fmt.Errorf("instantiating a server: %w", err) } http.Handle("/xrpc/com.atproto.label.subscribeLabels", server.Subscribe()) http.Handle("/xrpc/com.atproto.label.queryLabels", server.Query()) http.ListenAndServe(":8080", nil)
Index ¶
- type Entry
- type Server
- func (s *Server) AddLabel(label comatproto.LabelDefs_Label) (bool, error)
- func (s *Server) DoNotUseUnlessYouKnowWhatYoureDoing_BumpLastKeyTo(n int64) error
- func (s *Server) ImportEntries(entries map[int64]comatproto.LabelDefs_Label) error
- func (s *Server) IsEmpty() (bool, error)
- func (s *Server) LabelEntries(ctx context.Context, labelName string) ([]comatproto.LabelDefs_Label, error)
- func (s *Server) Query() http.Handler
- func (s *Server) SetAllowedLabels(labels []string)
- func (s *Server) Subscribe() http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry comatproto.LabelDefs_Label
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AddLabel ¶
func (s *Server) AddLabel(label comatproto.LabelDefs_Label) (bool, error)
AddLabel updates the internal state and writes the label to the database.
Note that it will ignore values that have no effect (e.g., if the label already exists, or trying to negate a label that doesn't exist). Return value indicates if there was a change or not.
func (*Server) DoNotUseUnlessYouKnowWhatYoureDoing_BumpLastKeyTo ¶
func (*Server) ImportEntries ¶ added in v0.2.0
func (s *Server) ImportEntries(entries map[int64]comatproto.LabelDefs_Label) error
ImportEntries populates an empty server with the given entries. Each entry is written at a sequence number equal to the map key.
Note that this method does not update the in-memory state of the server, so it must be restarted before serving any requests.
func (*Server) IsEmpty ¶ added in v0.2.0
IsEmpty returns true if there are no labels in the database.
func (*Server) LabelEntries ¶
func (s *Server) LabelEntries(ctx context.Context, labelName string) ([]comatproto.LabelDefs_Label, error)
LabelEntries returns all non-negated label entries for the provided label name. Does not filter out expired entries.
func (*Server) Query ¶
Query returns HTTP handler that implements [com.atproto.label.queryLabels](https://docs.bsky.app/docs/api/com-atproto-label-query-labels) XRPC method.
func (*Server) SetAllowedLabels ¶
SetAllowedLabels limits what label values can be used for new labels. Old existing labels are not affected, and label negations are also always allowed. By default all labels are allowed.