Documentation
¶
Overview ¶
Package whadmin is what an administrator does to a webhook source (#1870): create one, change it, rotate its secret, read its status, and delete it.
Creating a source is more than writing its record. Its tables and view are created on the connection it names, and the connection is proved able to hold them -- its catalog reads the managed-resources bucket and allows register_partition -- before the source is stored, so a source the platform accepts is one whose events can be queried. The table is recorded as a registration, which is how the table listing and every surface reading registrations sees it.
Index ¶
- Variables
- type Deps
- type Objects
- type Registrations
- type Resources
- type Service
- func (s *Service) Create(ctx context.Context, src whsource.Source) (whsource.Source, error)
- func (s *Service) Delete(ctx context.Context, name string) error
- func (s *Service) Get(ctx context.Context, name string) (whsource.Source, whstore.Status, error)
- func (s *Service) List(ctx context.Context) ([]whsource.Source, error)
- func (s *Service) Update(ctx context.Context, name string, u Update) (whsource.Source, error)
- type Sources
- type Tables
- type Update
- type Windows
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = whsource.ErrNotFound ErrExists = whsource.ErrExists ErrNameTaken = errors.New("a table with this source's name is already registered on that connection") // ErrUnusable wraps the reason a connection could not hold the source's // tables, as the query engine gave it. ErrUnusable = errors.New("the connection cannot hold this source's table") )
Refusals a request can meet, beyond whsource.ErrInvalid and the table package's connection refusals.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Sources Sources
Tables Tables
Registrations Registrations
Windows Windows
Objects Objects
Resources Resources
Bucket string
// Changed is called after every write, so this replica's receiver
// serves the change at once rather than at its next refresh.
Changed func()
// PersonaExists reports whether a persona is defined, so a source cannot
// name one nobody belongs to. Nil accepts any name.
PersonaExists func(name string) bool
NewID func() (string, error)
Logger *slog.Logger
Now func() time.Time
}
Deps are what the service acts through.
type Objects ¶
type Objects interface {
ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
DeleteObject(ctx context.Context, bucket, key string) error
}
Objects lists and deletes what a source wrote outside the resource store.
type Registrations ¶
type Registrations interface {
Insert(ctx context.Context, r tableregister.Registration) error
ByName(ctx context.Context, connection, catalog, schema, table string) (*tableregister.Registration, error)
BySource(ctx context.Context, kind, sourceID string) ([]tableregister.Registration, error)
Delete(ctx context.Context, id string) error
}
Registrations records the source's table. tableregister's store satisfies it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages sources.
func (*Service) Create ¶
Create makes a source: its tables, the proof its connection can hold them, its record and its registration. A failure part-way removes what was made.
func (*Service) Delete ¶
Delete removes a source and everything it wrote: its tables, its windows' resources, its raw segments, its registration and its record.
func (*Service) Update ¶
Update changes a source's settings. The name, the connection and the persona stay: the table was created on that connection under a name derived from the source's, and the windows already written are in that persona's library. An empty secret keeps the stored one, so a form never has to carry it.
type Sources ¶
type Sources interface {
List(ctx context.Context) ([]whsource.Source, error)
Get(ctx context.Context, name string) (whsource.Source, error)
Create(ctx context.Context, src whsource.Source) error
Update(ctx context.Context, src whsource.Source) error
Delete(ctx context.Context, name string) error
}
Sources is the source record store. whsource.Store satisfies it.
type Tables ¶
type Tables interface {
TargetFor(connection string) (whtable.Target, error)
S3Location(prefix string) string
Create(ctx context.Context, tg whtable.Target, src whsource.Source) error
Probe(ctx context.Context, tg whtable.Target, src whsource.Source) error
Drop(ctx context.Context, tg whtable.Target, src whsource.Source) error
}
Tables is the query-engine side. whtable.Tables satisfies it.