go-fed / activity

ActivityStreams & ActivityPub in golang, oh my!
BSD 3-Clause "New" or "Revised" License
703 stars 112 forks source link

Migrate `streams.Resolver` to `vocab.Resolver` #68

Closed cjslep closed 5 years ago

cjslep commented 5 years ago

Also, have it pass-through the raw vocab types directly to callbackers.

This will be an API breaking change for pub.Callbacker and streams.Resolver callbacks

Old code:

var r = &streams.Resolver{
  CreateCallback: myFuncUsingStreams, // or myFuncUsingRaw
}

func myFuncUsingStreams(s streams.Create) {
  resolution, iri := s.GetActor(0)
}

func myFuncUsingRaw(s streams.Create) {
  raw := s.Raw()
  iri := raw.GetActorIRI(0)
}

New code:

var r = &vocab.Resolver{
  CreateCallback: myFuncUsingStreams, // or myFuncUsingRaw
}

func myFuncUsingStreams(v vocab.Create) {
  s := streams.Create{Raw: v}
  resolution, iri := s.GetActor(0)
}

func myFuncUsingRaw(v vocab.Create) {
  iri := v.GetActorIRI(0)
}

I hope this is not a painful transition. It unblocks several other design and feature issues:

cjslep commented 5 years ago

The latest merge into tools/exp will now autogenerate resolvers as part of its comprehensive generation process.