diff --git a/cmd/collector/main.go b/cmd/collector/main.go index 8e9b8d7..100a341 100644 --- a/cmd/collector/main.go +++ b/cmd/collector/main.go @@ -60,6 +60,12 @@ func run(cfg config.CollectorCLIConfig, logger *slog.Logger) error { g, gctx := errgroup.WithContext(ctx) g.Go(server.Serve) + g.Go(func() error { + if err := server.RunFlows(gctx); !errors.Is(err, context.Canceled) { + return err + } + return nil + }) g.Go(func() error { if err := analyzer.Run(gctx); !errors.Is(err, context.Canceled) { return err diff --git a/internal/collector/flows.go b/internal/collector/flows.go new file mode 100644 index 0000000..ffae9dc --- /dev/null +++ b/internal/collector/flows.go @@ -0,0 +1,129 @@ +package collector + +import ( + "context" + "encoding/json" + "fmt" + "sync" + "time" + + "github.com/cap-theorem/spectral/internal/wire" +) + +const FlowsPath = "/v1/flows" + +const ( + maxFlowsPerReport = 4096 + maxPendingFlows = 50_000 + flowSubBuffer = 32 + FlowFlushInterval = 100 * time.Millisecond +) + +type FlowReport struct { + ID wire.NodeID `json:"id"` + Flows []Flow `json:"flows"` +} + +type Flow struct { + To wire.NodeID `json:"to"` + Kind string `json:"kind"` + Count uint32 `json:"count"` +} + +func (r FlowReport) Validate() error { + if r.ID == (wire.NodeID{}) { + return fmt.Errorf("%w: id is required", ErrInvalidReport) + } + if len(r.Flows) > maxFlowsPerReport { + return fmt.Errorf("%w: %d flows exceeds limit %d", ErrInvalidReport, len(r.Flows), maxFlowsPerReport) + } + for _, f := range r.Flows { + if f.To == (wire.NodeID{}) || f.To == r.ID { + return fmt.Errorf("%w: flow target must be another node's id", ErrInvalidReport) + } + if f.Kind == "" || f.Count == 0 { + return fmt.Errorf("%w: flow needs a kind and a count", ErrInvalidReport) + } + } + return nil +} + +type FlowEvent struct { + From wire.NodeID `json:"from"` + To wire.NodeID `json:"to"` + Kind string `json:"kind"` + Count uint32 `json:"count"` +} + +type FlowBatch struct { + At time.Time `json:"at"` + Flows []FlowEvent `json:"flows"` +} + +type flowHub struct { + mu sync.Mutex + pending []FlowEvent + dropped int + subs map[chan []byte]struct{} +} + +func newFlowHub() *flowHub { + return &flowHub{subs: make(map[chan []byte]struct{})} +} + +func (h *flowHub) add(r FlowReport) { + h.mu.Lock() + defer h.mu.Unlock() + if len(h.subs) == 0 { + return + } + for _, f := range r.Flows { + if len(h.pending) >= maxPendingFlows { + h.dropped++ + continue + } + h.pending = append(h.pending, FlowEvent{From: r.ID, To: f.To, Kind: f.Kind, Count: f.Count}) + } +} + +func (h *flowHub) flush(now time.Time) { + h.mu.Lock() + defer h.mu.Unlock() + if len(h.pending) == 0 { + return + } + b, _ := json.Marshal(FlowBatch{At: now, Flows: h.pending}) + h.pending = nil + for ch := range h.subs { + select { + case ch <- b: + default: + } + } +} + +func (h *flowHub) subscribe() (<-chan []byte, func()) { + h.mu.Lock() + defer h.mu.Unlock() + ch := make(chan []byte, flowSubBuffer) + h.subs[ch] = struct{}{} + cancel := func() { + h.mu.Lock() + defer h.mu.Unlock() + delete(h.subs, ch) + } + return ch, cancel +} + +func (h *flowHub) run(ctx context.Context, every time.Duration) error { + t := time.NewTicker(every) + defer t.Stop() + for { + select { + case <-ctx.Done(): + return ctx.Err() + case now := <-t.C: + h.flush(now) + } + } +} diff --git a/internal/collector/flows_test.go b/internal/collector/flows_test.go new file mode 100644 index 0000000..446dccc --- /dev/null +++ b/internal/collector/flows_test.go @@ -0,0 +1,119 @@ +package collector + +import ( + "bufio" + "bytes" + "encoding/json" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + "uuid" +) + +func TestFlowReportValidate(t *testing.T) { + x, y := uuid.NewV4(), uuid.NewV4() + for name, r := range map[string]FlowReport{ + "no id": {Flows: []Flow{{To: y, Kind: "ping", Count: 1}}}, + "self": {ID: x, Flows: []Flow{{To: x, Kind: "ping", Count: 1}}}, + "no target": {ID: x, Flows: []Flow{{Kind: "ping", Count: 1}}}, + "no kind": {ID: x, Flows: []Flow{{To: y, Count: 1}}}, + "zero count": {ID: x, Flows: []Flow{{To: y, Kind: "ping"}}}, + } { + if r.Validate() == nil { + t.Errorf("%s: valid", name) + } + } + if err := (FlowReport{ID: x, Flows: []Flow{{To: y, Kind: "ping", Count: 3}}}).Validate(); err != nil { + t.Fatal(err) + } +} + +func TestFlowHubSkipsWithoutSubscribers(t *testing.T) { + h := newFlowHub() + h.add(FlowReport{ID: uuid.NewV4(), Flows: []Flow{{To: uuid.NewV4(), Kind: "ping", Count: 1}}}) + if len(h.pending) != 0 { + t.Fatal("buffered flows with nobody watching") + } +} + +func TestFlowHubSlowSubscriberMissesBatches(t *testing.T) { + h := newFlowHub() + ch, cancel := h.subscribe() + defer cancel() + r := FlowReport{ID: uuid.NewV4(), Flows: []Flow{{To: uuid.NewV4(), Kind: "ping", Count: 1}}} + for range flowSubBuffer + 5 { + h.add(r) + h.flush(time.Now()) + } + if len(ch) != flowSubBuffer { + t.Fatalf("buffered %d batches, want %d", len(ch), flowSubBuffer) + } + if len(h.subs) != 1 { + t.Fatal("slow subscriber was dropped") + } +} + +func TestServerFlowsStream(t *testing.T) { + g := NewGraph() + a := NewAnalyzer(AnalyzerConfig{StaleAfter: time.Minute}, g, slog.New(slog.DiscardHandler)) + s := NewServer(ServerConfig{}, g, a, Metrics{}, slog.New(slog.DiscardHandler)) + srv := httptest.NewServer(s.Handler()) + t.Cleanup(srv.Close) + + resp, err := http.Get(srv.URL + "/v1/flows/stream") + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + if resp.Header.Get("Access-Control-Allow-Origin") != "*" { + t.Fatal("flow stream not readable cross-origin") + } + lines := bufio.NewScanner(resp.Body) + if !lines.Scan() || lines.Text() != ": flows" { + t.Fatalf("first line %q", lines.Text()) + } + + x, y := uuid.NewV4(), uuid.NewV4() + post := func(r FlowReport) int { + b, _ := json.Marshal(r) + resp, err := http.Post(srv.URL+FlowsPath, "application/json", bytes.NewReader(b)) + if err != nil { + t.Fatal(err) + } + resp.Body.Close() + return resp.StatusCode + } + if code := post(FlowReport{ID: x, Flows: []Flow{{To: x, Kind: "ping", Count: 1}}}); code != http.StatusBadRequest { + t.Fatalf("self flow: status %d", code) + } + if code := post(FlowReport{ID: x, Flows: []Flow{{To: y, Kind: "heartbeat", Count: 2}}}); code != http.StatusNoContent { + t.Fatalf("flow: status %d", code) + } + s.flows.flush(time.Now()) + + var event, data string + for lines.Scan() { + line := lines.Text() + if v, ok := strings.CutPrefix(line, "event: "); ok { + event = v + } + if v, ok := strings.CutPrefix(line, "data: "); ok { + data = v + break + } + } + if event != "flows" { + t.Fatalf("event %q", event) + } + var b FlowBatch + if err := json.Unmarshal([]byte(data), &b); err != nil { + t.Fatal(err) + } + want := FlowEvent{From: x, To: y, Kind: "heartbeat", Count: 2} + if len(b.Flows) != 1 || b.Flows[0] != want { + t.Fatalf("batch = %+v", b) + } +} diff --git a/internal/collector/server.go b/internal/collector/server.go index 08d9c8e..c1b601a 100644 --- a/internal/collector/server.go +++ b/internal/collector/server.go @@ -28,10 +28,11 @@ type Server struct { logger *slog.Logger server *http.Server streams context.Context + flows *flowHub } func NewServer(cfg ServerConfig, g *Graph, a *Analyzer, m Metrics, logger *slog.Logger) *Server { - s := &Server{graph: g, analyzer: a, metrics: m, logger: logger} + s := &Server{graph: g, analyzer: a, metrics: m, logger: logger, flows: newFlowHub()} // No request logging: ingest is most of the traffic. r := chi.NewRouter() @@ -40,6 +41,7 @@ func NewServer(cfg ServerConfig, g *Graph, a *Analyzer, m Metrics, logger *slog. r.Group(func(r chi.Router) { r.Use(middleware.Timeout(5 * time.Second)) r.Post(ReportPath, s.handleReport) + r.Post(FlowsPath, s.handleFlows) r.Get("/healthz", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) }) }) // Read-only, so any origin may read it (e.g. a frontend dev server). @@ -48,6 +50,7 @@ func NewServer(cfg ServerConfig, g *Graph, a *Analyzer, m Metrics, logger *slog. r.With(middleware.Timeout(5*time.Second)).Get("/v1/summary", s.handleSummary) r.With(middleware.Timeout(5*time.Second), middleware.Compress(5, "application/json")).Get("/v1/graph", s.handleGraph) r.Get("/v1/graph/stream", s.handleStream) + r.Get("/v1/flows/stream", s.handleFlowStream) }) s.server = &http.Server{ @@ -76,6 +79,8 @@ func (s *Server) Serve() error { return err } +func (s *Server) RunFlows(ctx context.Context) error { return s.flows.run(ctx, FlowFlushInterval) } + func (s *Server) Shutdown(ctx context.Context) error { return s.server.Shutdown(ctx) } func (s *Server) Close() error { return s.server.Close() } @@ -102,6 +107,53 @@ func (s *Server) handleReport(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) } +func (s *Server) handleFlows(w http.ResponseWriter, r *http.Request) { + var rep FlowReport + if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxReportBytes)).Decode(&rep); err != nil { + writeError(w, http.StatusBadRequest, err) + return + } + if err := rep.Validate(); err != nil { + writeError(w, http.StatusBadRequest, err) + return + } + s.flows.add(rep) + w.WriteHeader(http.StatusNoContent) +} + +func (s *Server) handleFlowStream(w http.ResponseWriter, r *http.Request) { + batches, cancel := s.flows.subscribe() + defer cancel() + + rc := http.NewResponseController(w) + _ = rc.SetWriteDeadline(time.Time{}) + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Cache-Control", "no-cache") + w.WriteHeader(http.StatusOK) + if _, err := fmt.Fprint(w, ": flows\n\n"); err != nil || rc.Flush() != nil { + return + } + + ping := time.NewTicker(15 * time.Second) + defer ping.Stop() + for { + select { + case <-r.Context().Done(): + return + case <-s.streams.Done(): + return + case b := <-batches: + if _, err := fmt.Fprintf(w, "event: flows\ndata: %s\n\n", b); err != nil || rc.Flush() != nil { + return + } + case <-ping.C: + if _, err := fmt.Fprint(w, ": ping\n\n"); err != nil || rc.Flush() != nil { + return + } + } + } +} + func (s *Server) handleSummary(w http.ResponseWriter, _ *http.Request) { sum := s.analyzer.Latest() if sum == nil { diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go index 0ba24d1..face4f6 100644 --- a/internal/daemon/daemon.go +++ b/internal/daemon/daemon.go @@ -74,8 +74,10 @@ func Run(cfg config.DaemonCLIConfig, logger *slog.Logger) error { nodeCtx, stopNode := context.WithCancel(context.Background()) var reports chan collector.Report + var flows chan collector.FlowReport if cfg.CollectorURL != "" { reports = make(chan collector.Report, 1) + flows = make(chan collector.FlowReport, 4) } node := node.NewNode( @@ -87,6 +89,7 @@ func Run(cfg config.DaemonCLIConfig, logger *slog.Logger) error { PongsReceived: pongsReceived, }, Telemetry: reports, + Flows: flows, }, tr, logger.With("component", "node"), @@ -115,6 +118,14 @@ func Run(cfg config.DaemonCLIConfig, logger *slog.Logger) error { g.Go(supervise("telemetry", stopping, func() error { return exporter.Run(stopping) })) + flowExporter := telemetry.NewFlowExporter( + telemetry.ExporterConfig{CollectorURL: cfg.CollectorURL}, + flows, + logger.With("component", "flows"), + ) + g.Go(supervise("flows", stopping, func() error { + return flowExporter.Run(stopping) + })) } var shutdownErr error diff --git a/internal/node/flows.go b/internal/node/flows.go new file mode 100644 index 0000000..ccea846 --- /dev/null +++ b/internal/node/flows.go @@ -0,0 +1,51 @@ +package node + +import ( + "cmp" + "slices" + "time" + + "github.com/cap-theorem/spectral/internal/collector" + "github.com/cap-theorem/spectral/internal/wire" +) + +const flowInterval = 250 * time.Millisecond + +type flowKey struct { + to wire.NodeID + kind wire.Kind +} + +func (n *Node) countFlow(to wire.NodeID, kind wire.Kind) { + if n.flowOut == nil || to == (wire.NodeID{}) || to == n.self.ID { + return + } + n.flows[flowKey{to: to, kind: kind}]++ +} + +func (n *Node) flowTick(now time.Time) { + if n.flowOut == nil || now.Before(n.nextFlows) { + return + } + n.nextFlows = now.Add(flowInterval) + if len(n.flows) == 0 { + return + } + + flows := make([]collector.Flow, 0, len(n.flows)) + for k, c := range n.flows { + flows = append(flows, collector.Flow{To: k.to, Kind: k.kind.String(), Count: c}) + } + clear(n.flows) + slices.SortFunc(flows, func(a, b collector.Flow) int { + if c := a.To.Compare(b.To); c != 0 { + return c + } + return cmp.Compare(a.Kind, b.Kind) + }) + + select { + case n.flowOut <- collector.FlowReport{ID: n.self.ID, Flows: flows}: + default: + } +} diff --git a/internal/node/flows_test.go b/internal/node/flows_test.go new file mode 100644 index 0000000..e7c47b2 --- /dev/null +++ b/internal/node/flows_test.go @@ -0,0 +1,87 @@ +package node + +import ( + "testing" + "time" + "uuid" + + "github.com/cap-theorem/spectral/internal/collector" + "github.com/cap-theorem/spectral/internal/wire" +) + +func TestFlowTickBatchesSends(t *testing.T) { + n := testNode() + n.flowOut = make(chan collector.FlowReport, 1) + t0 := time.Unix(100, 0) + + a, b := wire.Peer{ID: uuid.NewV4()}, wire.Peer{ID: uuid.NewV4()} + n.send(a, wire.Heartbeat{}) + n.send(a, wire.Heartbeat{}) + n.send(a, wire.Ping{}) + n.send(b, wire.Update{}) + n.send(wire.Peer{}, wire.Ping{}) + n.send(n.self, wire.Ping{}) + + n.flowTick(t0) + r := <-n.flowOut + if r.ID != n.self.ID || len(r.Flows) != 3 { + t.Fatalf("report = %+v", r) + } + want := map[[2]string]uint32{ + {a.ID.String(), "heartbeat"}: 2, + {a.ID.String(), "ping"}: 1, + {b.ID.String(), "update"}: 1, + } + for _, f := range r.Flows { + if want[[2]string{f.To.String(), f.Kind}] != f.Count { + t.Fatalf("unexpected flow %+v", f) + } + } + for i := 1; i < len(r.Flows); i++ { + if c := r.Flows[i-1].To.Compare(r.Flows[i].To); c > 0 || (c == 0 && r.Flows[i-1].Kind > r.Flows[i].Kind) { + t.Fatalf("flows not sorted: %+v", r.Flows) + } + } + + n.send(a, wire.Pong{}) + n.flowTick(t0.Add(flowInterval / 2)) + if len(n.flowOut) != 0 { + t.Fatal("flushed before flowInterval") + } + n.flowTick(t0.Add(flowInterval)) + if r := <-n.flowOut; len(r.Flows) != 1 || r.Flows[0].Kind != "pong" { + t.Fatalf("second batch = %+v", r) + } + + n.flowTick(t0.Add(2 * flowInterval)) + if len(n.flowOut) != 0 { + t.Fatal("sent an empty batch") + } +} + +func TestFlowTickDropsWhenExporterBusy(t *testing.T) { + n := testNode() + n.flowOut = make(chan collector.FlowReport, 1) + t0 := time.Unix(100, 0) + p := wire.Peer{ID: uuid.NewV4()} + + n.send(p, wire.Ping{}) + n.flowTick(t0) + n.send(p, wire.Pong{}) + n.flowTick(t0.Add(flowInterval)) + + if r := <-n.flowOut; r.Flows[0].Kind != "ping" { + t.Fatalf("kept %+v, want the first batch", r) + } + if len(n.flows) != 0 { + t.Fatal("dropped batch still counted") + } +} + +func TestNoFlowsWithoutCollector(t *testing.T) { + n := testNode() + n.send(wire.Peer{ID: uuid.NewV4()}, wire.Ping{}) + if len(n.flows) != 0 { + t.Fatal("counted flows with no collector") + } +} diff --git a/internal/node/node.go b/internal/node/node.go index b3132b8..78541e9 100644 --- a/internal/node/node.go +++ b/internal/node/node.go @@ -43,6 +43,10 @@ type Node struct { lastReport []collector.ReportLink nextReport time.Time keepalive time.Time + + flowOut chan collector.FlowReport + flows map[flowKey]uint32 + nextFlows time.Time } type NodeMetrics struct { @@ -62,6 +66,7 @@ type NodeConfig struct { Overlay OverlayKind Metrics NodeMetrics Telemetry chan collector.Report + Flows chan collector.FlowReport } func NewNode(cfg NodeConfig, tr transport.Transport, logger *slog.Logger) *Node { @@ -83,6 +88,8 @@ func NewNode(cfg NodeConfig, tr transport.Transport, logger *slog.Logger) *Node metrics: cfg.Metrics, pendingPing: make(map[uint64]pendingPing), telemetry: cfg.Telemetry, + flowOut: cfg.Flows, + flows: make(map[flowKey]uint32), } n.reg.merge(wire.Record{Peer: self, Status: wire.StatusAlive}, time.Now()) @@ -205,6 +212,7 @@ func (n *Node) tick(now time.Time) { n.expireLease(now) n.expirePings(now) n.reportTick(now) + n.flowTick(now) } func (n *Node) handleRequest(req request) { @@ -293,6 +301,7 @@ func (n *Node) handleEnvelope(env wire.Envelope) { } func (n *Node) send(to wire.Peer, msg wire.Message) { + n.countFlow(to.ID, msg.Kind()) n.transport.Send(to.Address, wire.Envelope{ From: n.self, To: to.ID, diff --git a/internal/telemetry/flows.go b/internal/telemetry/flows.go new file mode 100644 index 0000000..0cb73f5 --- /dev/null +++ b/internal/telemetry/flows.go @@ -0,0 +1,77 @@ +package telemetry + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "log/slog" + "net/http" + "strings" + "time" + + "github.com/cap-theorem/spectral/internal/collector" +) + +const flowPushTimeout = time.Second + +type FlowExporter struct { + url string + flows <-chan collector.FlowReport + client *http.Client + logger *slog.Logger +} + +func NewFlowExporter(cfg ExporterConfig, flows <-chan collector.FlowReport, logger *slog.Logger) *FlowExporter { + return &FlowExporter{ + url: strings.TrimRight(cfg.CollectorURL, "/") + collector.FlowsPath, + flows: flows, + client: &http.Client{Timeout: flowPushTimeout}, + logger: logger, + } +} + +func (e *FlowExporter) Run(ctx context.Context) error { + failing := false + for { + select { + case <-ctx.Done(): + return ctx.Err() + case r := <-e.flows: + err := e.push(ctx, r) + switch { + case err != nil && !failing: + e.logger.Warn("flow report failed, dropping flows until it recovers", "err", err) + failing = true + case err == nil && failing: + e.logger.Info("flow reports recovered") + failing = false + } + } + } +} + +func (e *FlowExporter) push(ctx context.Context, r collector.FlowReport) error { + body, err := json.Marshal(r) + if err != nil { + return err + } + req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.url, bytes.NewReader(body)) + if err != nil { + return err + } + req.Header.Set("Content-Type", "application/json") + + resp, err := e.client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + _, _ = io.Copy(io.Discard, resp.Body) + + if resp.StatusCode >= 300 { + return fmt.Errorf("collector answered %s", resp.Status) + } + return nil +} diff --git a/internal/telemetry/flows_test.go b/internal/telemetry/flows_test.go new file mode 100644 index 0000000..cf7eae5 --- /dev/null +++ b/internal/telemetry/flows_test.go @@ -0,0 +1,62 @@ +package telemetry + +import ( + "context" + "encoding/json" + "log/slog" + "net/http" + "net/http/httptest" + "sync/atomic" + "testing" + "time" + "uuid" + + "github.com/cap-theorem/spectral/internal/collector" +) + +func TestFlowExporterPostsAndDropsOnFailure(t *testing.T) { + var status atomic.Int32 + status.Store(http.StatusInternalServerError) + got := make(chan collector.FlowReport, 16) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + var rep collector.FlowReport + if r.Method != http.MethodPost || r.URL.Path != collector.FlowsPath || json.NewDecoder(r.Body).Decode(&rep) != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + got <- rep + w.WriteHeader(int(status.Load())) + })) + t.Cleanup(srv.Close) + + flows := make(chan collector.FlowReport) + ctx, cancel := context.WithCancel(t.Context()) + done := make(chan error, 1) + go func() { + done <- NewFlowExporter(ExporterConfig{CollectorURL: srv.URL + "/"}, flows, slog.New(slog.DiscardHandler)).Run(ctx) + }() + + id := uuid.NewV4() + first := collector.FlowReport{ID: id, Flows: []collector.Flow{{To: uuid.NewV4(), Kind: "ping", Count: 1}}} + second := collector.FlowReport{ID: id, Flows: []collector.Flow{{To: uuid.NewV4(), Kind: "pong", Count: 1}}} + + flows <- first + if r := <-got; r.Flows[0].Kind != "ping" { + t.Fatalf("got %+v", r) + } + status.Store(http.StatusNoContent) + flows <- second + select { + case r := <-got: + if r.Flows[0].Kind != "pong" { + t.Fatalf("retried a failed batch: %+v", r) + } + case <-time.After(2 * time.Second): + t.Fatal("no second post") + } + + cancel() + if err := <-done; err != context.Canceled { + t.Fatalf("Run = %v", err) + } +} diff --git a/internal/wire/message.go b/internal/wire/message.go index 61134eb..9f57d96 100644 --- a/internal/wire/message.go +++ b/internal/wire/message.go @@ -120,3 +120,34 @@ type PingReqAck struct { } func (PingReqAck) Kind() Kind { return KindPingReqAck } + +func (k Kind) String() string { + switch k { + case KindHeartbeat: + return "heartbeat" + case KindLink: + return "link" + case KindLinkAck: + return "link_ack" + case KindUnlink: + return "unlink" + case KindUpdate: + return "update" + case KindAEDigest: + return "ae_digest" + case KindAEHeads: + return "ae_heads" + case KindAEWant: + return "ae_want" + case KindPing: + return "ping" + case KindPong: + return "pong" + case KindPingReq: + return "ping_req" + case KindPingReqAck: + return "ping_req_ack" + default: + return "unknown" + } +}