Documentation
¶
Overview ¶
Package e2e is hearth's end-to-end demo app: an in-memory note service on the generated permission checks and MCP tools of testdata/e2e/proto/frostyard/demo/v1/demo.proto.
The package is documentation as much as test: it shows what an app writes itself, and what the plugins write for it. The API comes from the generated interface, the permission check of each RPC from protoc-gen-hearth-authz, the hooks that resolve a stored note's group from the app, the tools from protoc-gen-hearth-mcp, and the list filter from the app.
Index ¶
- type NoteService
- func (s *NoteService) AuthorizeCreateNote(_ context.Context, _ *store, grant authz.Grant, req *demov1.CreateNoteRequest) error
- func (s *NoteService) AuthorizeGetNote(_ context.Context, tx *store, grant authz.Grant, req *demov1.GetNoteRequest) error
- func (s *NoteService) AuthorizeMoveNote(_ context.Context, tx *store, grant authz.Grant, req *demov1.MoveNoteRequest) error
- func (s *NoteService) AuthorizePublishNote(_ context.Context, tx *store, grant authz.Grant, ...) error
- func (s *NoteService) CreateNote(ctx context.Context, req *demov1.CreateNoteRequest) (*demov1.CreateNoteResponse, error)
- func (s *NoteService) GetNote(ctx context.Context, req *demov1.GetNoteRequest) (*demov1.GetNoteResponse, error)
- func (s *NoteService) ListNotes(ctx context.Context, req *demov1.ListNotesRequest) (*demov1.ListNotesResponse, error)
- func (s *NoteService) MoveNote(ctx context.Context, req *demov1.MoveNoteRequest) (*demov1.MoveNoteResponse, error)
- func (s *NoteService) PublishNote(ctx context.Context, req *demov1.PublishNoteRequest) (*demov1.PublishNoteResponse, error)
- func (s *NoteService) SeedNote(id, group string)
- func (s *NoteService) Wired() demov1.NoteServiceAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoteService ¶
type NoteService struct {
// contains filtered or unexported fields
}
NoteService is the demo app: an in-memory note service.
The app holds its own lock, and its transaction is the lock: 1 RPC that runs on an object id holds the lock from its hook to its end, so the note the hook checked is the note the RPC changes.
func (*NoteService) AuthorizeCreateNote ¶
func (s *NoteService) AuthorizeCreateNote(_ context.Context, _ *store, grant authz.Grant, req *demov1.CreateNoteRequest) error
AuthorizeCreateNote checks the group the new note goes to. A new note has no stored group, so the request carries the object's value.
func (*NoteService) AuthorizeGetNote ¶
func (s *NoteService) AuthorizeGetNote(_ context.Context, tx *store, grant authz.Grant, req *demov1.GetNoteRequest) error
AuthorizeGetNote checks the group the note is stored in. The generated check has already read the capability from the grant: a hook resolves the object.
func (*NoteService) AuthorizeMoveNote ¶
func (s *NoteService) AuthorizeMoveNote(_ context.Context, tx *store, grant authz.Grant, req *demov1.MoveNoteRequest) error
AuthorizeMoveNote checks the group the note leaves. The destination is the request's selector value, and the generated check reads it.
func (*NoteService) AuthorizePublishNote ¶
func (s *NoteService) AuthorizePublishNote(_ context.Context, tx *store, grant authz.Grant, req *demov1.PublishNoteRequest) error
AuthorizePublishNote checks the group the note is stored in.
func (*NoteService) CreateNote ¶
func (s *NoteService) CreateNote(ctx context.Context, req *demov1.CreateNoteRequest) (*demov1.CreateNoteResponse, error)
CreateNote writes 1 note.
func (*NoteService) GetNote ¶
func (s *NoteService) GetNote(ctx context.Context, req *demov1.GetNoteRequest) (*demov1.GetNoteResponse, error)
GetNote reads 1 note.
func (*NoteService) ListNotes ¶
func (s *NoteService) ListNotes(ctx context.Context, req *demov1.ListNotesRequest) (*demov1.ListNotesResponse, error)
ListNotes reads the notes of 1 group, and filters each of them with the caller's grant: the generated check reads the request's group, and a note of another group is left out.
func (*NoteService) MoveNote ¶
func (s *NoteService) MoveNote(ctx context.Context, req *demov1.MoveNoteRequest) (*demov1.MoveNoteResponse, error)
MoveNote moves 1 note to another group.
func (*NoteService) PublishNote ¶
func (s *NoteService) PublishNote(ctx context.Context, req *demov1.PublishNoteRequest) (*demov1.PublishNoteResponse, error)
PublishNote reports where 1 note went.
func (*NoteService) SeedNote ¶
func (s *NoteService) SeedNote(id, group string)
SeedNote stores 1 note, as the app's startup does, with no permission check.
func (*NoteService) Wired ¶
func (s *NoteService) Wired() demov1.NoteServiceAPI
Wired returns the API with the generated permission check of every RPC.
An app serves this API on its own sockets: the stdio MCP server, its private socket and its lodge socket all reach it, each with its own caller.