Etymonline
⌘ Read more
@jlj@twt.nfld.uk @xuu@txt.sour.is hello! @prologic@twtxt.net and I were chatting about the question of globally deleting twts from the yarn.social network. @prologic@twtxt.net noted that he could build the tools and endpoints to delete twts, but some amount of cooperation from pod operators would be necessary to make it all work together. He asked me to spawn a discussion of the subject here, so here we are!
I don’t have enough technical knowledge of yarn.social to say with any credibility how it all should work, but I can say that I think it ought to be possible and it’d be good to do for those rare times when it’s needed.
just wrote a note in my code float* output; /* to write output to physical device, or just the next lower device in the abstraction tower */
feeling pretty proud of that LoL #coding #klebe
#TIL pencil writing is more permanent and waterproof than most ink. good news, I love pencils! #eco #notes
(cont.)
Just to give some context on some of the components around the code structure.. I wrote this up around an earlier version of aggregate code. This generic bit simplifies things by removing the need of the Crud functions for each aggregate.
Domain ObjectsA domain object can be used as an aggregate by adding the event.AggregateRoot
struct and finish implementing event.Aggregate. The AggregateRoot implements logic for adding events after they are either Raised by a command or Appended by the eventstore Load or service ApplyFn methods. It also tracks the uncommitted events that are saved using the eventstore Save method.
type User struct {
Identity string ```json:"identity"`
CreatedAt time.Time
event.AggregateRoot
}
// StreamID for the aggregate when stored or loaded from ES.
func (a *User) StreamID() string {
return "user-" + a.Identity
}
// ApplyEvent to the aggregate state.
func (a *User) ApplyEvent(lis ...event.Event) {
for _, e := range lis {
switch e := e.(type) {
case *UserCreated:
a.Identity = e.Identity
a.CreatedAt = e.EventMeta().CreatedDate
/* ... */
}
}
}
Events
Events are applied to the aggregate. They are defined by adding the event.Meta
and implementing the getter/setters for event.Event
type UserCreated struct {
eventMeta event.Meta
Identity string
}
func (c *UserCreated) EventMeta() (m event.Meta) {
if c != nil {
m = c.eventMeta
}
return m
}
func (c *UserCreated) SetEventMeta(m event.Meta) {
if c != nil {
c.eventMeta = m
}
}
Reading Events from EventStore
With a domain object that implements the event.Aggregate
the event store client can load events and apply them using the Load(ctx, agg)
method.
// GetUser populates an user from event store.
func (rw *User) GetUser(ctx context.Context, userID string) (*domain.User, error) {
user := &domain.User{Identity: userID}
err := rw.es.Load(ctx, user)
if err != nil {
if err != nil {
if errors.Is(err, eventstore.ErrStreamNotFound) {
return user, ErrNotFound
}
return user, err
}
return nil, err
}
return user, err
}
OnX Commands
An OnX command will validate the state of the domain object can have the command performed on it. If it can be applied it raises the event using event.Raise() Otherwise it returns an error.
// OnCreate raises an UserCreated event to create the user.
// Note: The handler will check that the user does not already exsist.
func (a *User) OnCreate(identity string) error {
event.Raise(a, &UserCreated{Identity: identity})
return nil
}
// OnScored will attempt to score a task.
// If the task is not in a Created state it will fail.
func (a *Task) OnScored(taskID string, score int64, attributes Attributes) error {
if a.State != TaskStateCreated {
return fmt.Errorf("task expected created, got %s", a.State)
}
event.Raise(a, &TaskScored{TaskID: taskID, Attributes: attributes, Score: score})
return nil
}
Crud Operations for OnX Commands
The following functions in the aggregate service can be used to perform creation and updating of aggregates. The Update function will ensure the aggregate exists, where the Create is intended for non-existent aggregates. These can probably be combined into one function.
// Create is used when the stream does not yet exist.
func (rw *User) Create(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil && !errors.Is(err, ErrNotFound) {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
// Update is used when the stream already exists.
func (rw *User) Update(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
@prologic@twtxt.net yeah. For commercial use even. Just need to put an attribution note in the project README
@prologic@twtxt.net, who calls me name when I am busy profiting? 😂 In a less serious note—because nothing is more serious than making profit, of course—yes, it seems your avatar issue has been fixed. I am kind of sad, I looked forward each day to see which random one was going to show. LOL.
Thanks to @TANTlab@twitter.com and @birkbak@birkbak.neocities.org for havning me today at AAU CPH🙏 Presentation notes can be found at: http://darch.dk/aau-tool-talk/
Common Cold Viruses
⌘ Read more
@stigatle@twtxt.net
Note taken. Thank you!
The features that macOS Monterey will bring, albeit minor, will made for a better “quality of living”. I am looking forward to Notes, and the iCloud+ integration (Private Relay, Hide My Email). It also bring macOS cohesively close to iOS. My work 2015 iMac and M1 Mini will get it, so looking forward to it!
Decided to keep the smart-phone out of our bedroom and keep a note book instead. Already feeling lighter and fresher.
Last year, we spent 51 days at sea during the passage from Japan to Canada, it was the hardest thing we had ever done. We kept a physical logbook of daily happenings onboard. This is that logbook, revised, and with a ton of extra notes. https://hundredrabbits.itch.io/busy-doing-nothing
i’ve been meaning to read these notes, maybe putting the book on my ereader will be a better reminder than whatever i did last time 😅
@xjix@xj-ix.luxe Saw your oldish note about wanting an offline/async twtxt workflow. Do you have something that works for you? My (very young!) client was designed with that in mind.
$ pico ~/.config/twtxt/config (note to self)
Another example of domestic computing: https://www.robinsloan.com/notes/home-cooked-app/
twtxt feels a little like launching simple digital bottle notes into the vast oceans of the Internet
$ cd gopherhole && vim notes/.
Funny how not that long ago I made a remark to a friend who was keeping all his notes as txt files and now I am looking at doing exactly that. txt will probably be the one format that will be around for a very long time still.
@lucidiot@tilde.town Agreeing that BuJo kind of saved my mind too. It now takes me about three months to fill up 251 pages with tasks, notes and events.
Updated my daily journal at gopher://gopher.johanbove.info:70/notes