-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
37 changed files
with
1,455 additions
and
11,324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/ | ||
.PHONY: help | ||
help: ## Display this help and any documented user-facing targets. Other undocumented targets may be present in the Makefile. | ||
help: | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " %-45s %s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
.DEFAULT_GOAL := all | ||
.PHONY: all clean-protos protos | ||
.PHONY: clean-protos | ||
|
||
SHELL = /usr/bin/env bash -o pipefail | ||
|
||
############# | ||
# Variables # | ||
############# | ||
|
||
# We don't want find to scan inside a bunch of directories, to accelerate the | ||
# 'make: Entering directory '/src/loki' phase. | ||
DONT_FIND := -name .swiftpm -prune -o -name .build -prune -o | ||
|
||
# Protobuf files | ||
PROTO_DEFS := $(shell find . $(DONT_FIND) -type f -name '*.proto' -print) | ||
PROTO_SWIFTS := $(patsubst %.proto,%.pb.swift,$(PROTO_DEFS)) | ||
|
||
################ | ||
# Main Targets # | ||
################ | ||
all: protos ## run all (clean-protos, protos) | ||
|
||
# This is really a check for the CI to make sure generated files are built and checked in manually | ||
check-generated-files: protos | ||
@if ! (git diff --exit-code $(PROTO_DEFS) $(PROTO_SWIFTS)); then \ | ||
echo "\nChanges found in generated files"; \ | ||
echo "Run 'make check-generated-files' and commit the changes to fix this error."; \ | ||
echo "If you are actively developing these files you can ignore this error"; \ | ||
echo "(Don't forget to check in the generated files when finished)\n"; \ | ||
exit 1; \ | ||
fi | ||
|
||
######### | ||
# Clean # | ||
######### | ||
|
||
clean-protos: ## remove swift protos | ||
rm -rf $(PROTO_SWIFTS) | ||
|
||
############# | ||
# Protobufs # | ||
############# | ||
|
||
protos: clean-protos $(PROTO_SWIFTS) ## regenerate swift protos | ||
|
||
%.pb.swift: | ||
protoc --swift_out=. $(patsubst %.pb.swift,%.proto,$@) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import Foundation | ||
|
||
struct Batch: Sendable { | ||
struct Batch<Clock: _Concurrency.Clock> { | ||
var entries: [BatchEntry] | ||
|
||
let createdAt = Date() | ||
let createdAt: Clock.Instant | ||
|
||
var totalLogEntries: Int { | ||
entries.flatMap { $0.logEntries }.count | ||
var totalLogEntries: Int | ||
|
||
init(entries: [BatchEntry], createdAt: Clock.Instant) { | ||
self.entries = entries | ||
self.createdAt = createdAt | ||
self.totalLogEntries = entries.flatMap(\.logEntries).count | ||
} | ||
|
||
mutating func addEntry(_ log: LokiLog, with labels: LokiLabels) { | ||
guard let index = entries.firstIndex(where: { $0.labels == labels }) else { | ||
mutating func addEntry(_ log: LokiLog.Transport, with labels: [String: String]) { | ||
if let index = entries.firstIndex(where: { $0.labels == labels }) { | ||
entries[index].logEntries.append(log) | ||
} else { | ||
entries.append(BatchEntry(labels: labels, logEntries: [log])) | ||
return | ||
} | ||
entries[index].logEntries.append(log) | ||
totalLogEntries += 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
struct BatchEntry: Sendable { | ||
var labels: LokiLabels | ||
var logEntries: [LokiLog] | ||
var labels: [String: String] | ||
var logEntries: [LokiLog.Transport] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.