Skip to content

Commit

Permalink
feat: awakari.app instance
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Jun 17, 2024
1 parent 2704e6a commit 9d05626
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ type Config struct {
Host string `envconfig:"API_HTTP_HOST" required:"true"`
Port uint16 `envconfig:"API_HTTP_PORT" default:"8080" required:"true"`
}
Port uint16 `envconfig:"API_PORT" default:"50051" required:"true"`
Writer struct {
Port uint16 `envconfig:"API_PORT" default:"50051" required:"true"`
EventType string `envconfig:"API_EVENT_TYPE" required:"true" default:"com.awakari.activitypub.v1"`
Writer struct {
Backoff time.Duration `envconfig:"API_WRITER_BACKOFF" default:"10s" required:"true"`
BatchSize uint32 `envconfig:"API_WRITER_BATCH_SIZE" default:"16" required:"true"`
Uri string `envconfig:"API_WRITER_URI" default:"resolver:50051" required:"true"`
Expand Down
2 changes: 2 additions & 0 deletions helm/int-activitypub/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
- name: API_HTTP_HOST
value: "{{ .host }}"
{{- end }}
- name: API_EVENT_TYPE
value: "{{ .Values.api.event.type }}"
- name: API_WRITER_BACKOFF
value: "{{ .Values.api.writer.backoff }}"
- name: API_WRITER_BATCH_SIZE
Expand Down
4 changes: 3 additions & 1 deletion helm/int-activitypub/values-awakari-app.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
api:
event:
type: "app.awakari.activitypub.v1"
writer:
uri: "api:50051"

Expand All @@ -7,7 +9,7 @@ cert:
acme:
server: "https://acme-v02.api.letsencrypt.org/directory"
issuer:
name: letsencrypt
name: letsencrypt-awakari-app

ingressHttpV1:
hosts:
Expand Down
10 changes: 6 additions & 4 deletions service/converter/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type Service interface {
}

type service struct {
ceType string
}

const CeType = "com.awakari.activitypub.v1"
const CeSpecVersion = "1.0"
const CeKeyAction = "action"
const CeKeyAttachmentUrl = "attachmenturl"
Expand Down Expand Up @@ -49,8 +49,10 @@ const asPublic = "https://www.w3.org/ns/activitystreams#Public"

var ErrFail = errors.New("failed to convert")

func NewService() Service {
return service{}
func NewService(ceType string) Service {
return service{
ceType: ceType,
}
}

func (svc service) Convert(ctx context.Context, actor vocab.Actor, activity vocab.Activity, tags util.ActivityTags) (evt *pb.CloudEvent, err error) {
Expand All @@ -59,7 +61,7 @@ func (svc service) Convert(ctx context.Context, actor vocab.Actor, activity voca
Id: uuid.NewString(),
Source: actor.ID.String(),
SpecVersion: CeSpecVersion,
Type: CeType,
Type: svc.ceType,
Attributes: map[string]*pb.CloudEventAttributeValue{
CeKeyTime: {
Attr: &pb.CloudEventAttributeValue_CeTimestamp{
Expand Down

0 comments on commit 9d05626

Please sign in to comment.