Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be36636a41 | ||
|
|
f6992c768e | ||
|
|
cae21ca3b3 | ||
|
|
fac6c2fcc0 | ||
|
|
da6ea54c96 | ||
|
|
a8ed507198 | ||
|
|
a13e71e828 | ||
|
|
cdca9d7a2d | ||
|
|
f2b1a4bbb1 | ||
|
|
72533b8f32 | ||
|
|
e7f6bcefa8 | ||
|
|
dca2d154c4 | ||
|
|
e1de7d9255 | ||
|
|
ffd0257f19 |
@@ -11,37 +11,24 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: docker
|
runs-on: golang
|
||||||
container:
|
container:
|
||||||
image: golang:1.25
|
image: golang:1.26
|
||||||
env:
|
env:
|
||||||
GOPRIVATE: forgejo.riotpiao.com
|
GOPRIVATE: forgejo.riotpiao.com
|
||||||
GOFLAGS: -mod=readonly
|
GOFLAGS: -mod=readonly
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
|
||||||
steps:
|
steps:
|
||||||
# actions/checkout is a Node-based action; golang:1.25 has no node on PATH.
|
# actions/checkout is a Node-based action; install node for Actions support.
|
||||||
- name: install node (required by JS-based actions)
|
- name: install node (required by JS-based actions)
|
||||||
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git
|
run: apt-get update && apt-get install -y --no-install-recommends nodejs ca-certificates git
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# kmsvc-proto lives in another private repo on the same Forgejo instance.
|
# kmsvc-proto lives in another private repo on the same Forgejo instance.
|
||||||
# GITHUB_TOKEN is auto-injected by Forgejo Actions and has read access to all repos.
|
|
||||||
- name: configure git auth for private module fetch
|
- name: configure git auth for private module fetch
|
||||||
run: |
|
run: |
|
||||||
git config --global url."https://oauth2:${GITHUB_TOKEN}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
|
git config --global url."https://oauth2:${REGISTRY_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: cache go modules + build cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cache/go-build
|
|
||||||
~/go/pkg/mod
|
|
||||||
key: go-${{ runner.os }}-${{ hashFiles('go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
go-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: gofmt
|
- name: gofmt
|
||||||
run: |
|
run: |
|
||||||
@@ -63,9 +50,3 @@ jobs:
|
|||||||
|
|
||||||
- name: coverage summary
|
- name: coverage summary
|
||||||
run: go tool cover -func=coverage.out | tail -1
|
run: go tool cover -func=coverage.out | tail -1
|
||||||
|
|
||||||
- name: upload coverage
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: coverage
|
|
||||||
path: coverage.out
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: docker
|
runs-on: golang
|
||||||
container:
|
container:
|
||||||
image: golang:1.25
|
image: golang:1.26
|
||||||
env:
|
env:
|
||||||
GOPRIVATE: forgejo.riotpiao.com
|
GOPRIVATE: forgejo.riotpiao.com
|
||||||
steps:
|
steps:
|
||||||
@@ -23,9 +23,9 @@ jobs:
|
|||||||
|
|
||||||
- name: configure git auth for private module fetch
|
- name: configure git auth for private module fetch
|
||||||
run: |
|
run: |
|
||||||
git config --global url."https://oauth2:${GITHUB_TOKEN}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
|
git config --global url."https://oauth2:${REGISTRY_PAT}@forgejo.riotpiao.com".insteadOf "https://forgejo.riotpiao.com"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
REGISTRY_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# A tag is the public contract for `go get [email protected]` — re-run the full
|
# A tag is the public contract for `go get [email protected]` — re-run the full
|
||||||
# gate before publishing a release, never trust that main was green.
|
# gate before publishing a release, never trust that main was green.
|
||||||
|
|||||||
@@ -56,3 +56,6 @@ go test ./... -race
|
|||||||
```
|
```
|
||||||
|
|
||||||
No `buf`/`protoc` install needed — `kmsvc-proto`'s generated Go code is consumed as a plain module dependency.
|
No `buf`/`protoc` install needed — `kmsvc-proto`'s generated Go code is consumed as a plain module dependency.
|
||||||
|
# Final test - clean cache removal
|
||||||
|
# Final CI validation - Forgejo ready
|
||||||
|
# CI cleanup - removed upload-artifact
|
||||||
|
|||||||
@@ -15,18 +15,18 @@ import (
|
|||||||
// Queue lifecycle (create/delete/configure) is managed via the Queue CRD, not
|
// Queue lifecycle (create/delete/configure) is managed via the Queue CRD, not
|
||||||
// this client — see kafaka_management_service design.md §2a/§2b.
|
// this client — see kafaka_management_service design.md §2a/§2b.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
conn *grpc.ClientConn
|
conn *grpc.ClientConn
|
||||||
stub kafkamgmtv1.QueueServiceClient
|
stub kafkamgmtv1.QueueServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option configures a Client during New.
|
// Option configures a Client during New.
|
||||||
type Option func(*options)
|
type Option func(*options)
|
||||||
|
|
||||||
type options struct {
|
type options struct {
|
||||||
tokenSource TokenSource
|
tokenSource TokenSource
|
||||||
tlsConfig credentials.TransportCredentials
|
tlsConfig credentials.TransportCredentials
|
||||||
dialTimeout time.Duration
|
dialTimeout time.Duration
|
||||||
dialOpts []grpc.DialOption
|
dialOpts []grpc.DialOption
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithTokenSource attaches a bearer token to every outgoing call via source.
|
// WithTokenSource attaches a bearer token to every outgoing call via source.
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ type sentinelError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *sentinelError) Error() string { return e.original.Error() }
|
func (e *sentinelError) Error() string { return e.original.Error() }
|
||||||
func (e *sentinelError) Unwrap() error { return e.original }
|
func (e *sentinelError) Unwrap() error { return e.original }
|
||||||
func (e *sentinelError) Is(target error) bool {
|
func (e *sentinelError) Is(target error) bool {
|
||||||
return target == e.sentinel
|
return target == e.sentinel
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func main() {
|
|||||||
|
|
||||||
msgs, err := client.ReceiveMessage(ctx, *queue, kmsvc.ReceiveOptions{
|
msgs, err := client.ReceiveMessage(ctx, *queue, kmsvc.ReceiveOptions{
|
||||||
MaxNumberOfMessages: 1,
|
MaxNumberOfMessages: 1,
|
||||||
WaitTimeSeconds: 10,
|
WaitTimeSeconds: 10,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("ReceiveMessage: %v", err)
|
log.Fatalf("ReceiveMessage: %v", err)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module forgejo.riotpiao.com/rock/kmsvc-sdk
|
module forgejo.riotpiao.com/rock/kmsvc-sdk
|
||||||
|
|
||||||
go 1.25.0
|
go 1.26.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
forgejo.riotpiao.com/rock/kmsvc-proto v1.4.0
|
forgejo.riotpiao.com/rock/kmsvc-proto v1.4.0
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import (
|
|||||||
type fakeQueueService struct {
|
type fakeQueueService struct {
|
||||||
kafkamgmtv1.UnimplementedQueueServiceServer
|
kafkamgmtv1.UnimplementedQueueServiceServer
|
||||||
|
|
||||||
sendMessage func(context.Context, *kafkamgmtv1.SendMessageRequest) (*kafkamgmtv1.SendMessageResponse, error)
|
sendMessage func(context.Context, *kafkamgmtv1.SendMessageRequest) (*kafkamgmtv1.SendMessageResponse, error)
|
||||||
sendMessageBatch func(context.Context, *kafkamgmtv1.SendMessageBatchRequest) (*kafkamgmtv1.SendMessageBatchResponse, error)
|
sendMessageBatch func(context.Context, *kafkamgmtv1.SendMessageBatchRequest) (*kafkamgmtv1.SendMessageBatchResponse, error)
|
||||||
receiveMessage func(context.Context, *kafkamgmtv1.ReceiveMessageRequest) (*kafkamgmtv1.ReceiveMessageResponse, error)
|
receiveMessage func(context.Context, *kafkamgmtv1.ReceiveMessageRequest) (*kafkamgmtv1.ReceiveMessageResponse, error)
|
||||||
deleteMessage func(context.Context, *kafkamgmtv1.DeleteMessageRequest) (*kafkamgmtv1.DeleteMessageResponse, error)
|
deleteMessage func(context.Context, *kafkamgmtv1.DeleteMessageRequest) (*kafkamgmtv1.DeleteMessageResponse, error)
|
||||||
deleteMessageBatch func(context.Context, *kafkamgmtv1.DeleteMessageBatchRequest) (*kafkamgmtv1.DeleteMessageBatchResponse, error)
|
deleteMessageBatch func(context.Context, *kafkamgmtv1.DeleteMessageBatchRequest) (*kafkamgmtv1.DeleteMessageBatchResponse, error)
|
||||||
changeMessageVisibility func(context.Context, *kafkamgmtv1.ChangeMessageVisibilityRequest) (*kafkamgmtv1.ChangeMessageVisibilityResponse, error)
|
changeMessageVisibility func(context.Context, *kafkamgmtv1.ChangeMessageVisibilityRequest) (*kafkamgmtv1.ChangeMessageVisibilityResponse, error)
|
||||||
|
|
||||||
// lastIncomingAuth captures the authorization header seen by the most
|
// lastIncomingAuth captures the authorization header seen by the most
|
||||||
// recent call, for interceptor assertions.
|
// recent call, for interceptor assertions.
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ func TestReceiveMessageMapsResponse(t *testing.T) {
|
|||||||
|
|
||||||
msgs, err := client.ReceiveMessage(context.Background(), "q", ReceiveOptions{
|
msgs, err := client.ReceiveMessage(context.Background(), "q", ReceiveOptions{
|
||||||
MaxNumberOfMessages: 5,
|
MaxNumberOfMessages: 5,
|
||||||
WaitTimeSeconds: 2,
|
WaitTimeSeconds: 2,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ReceiveMessage: %v", err)
|
t.Fatalf("ReceiveMessage: %v", err)
|
||||||
|
|||||||
+12
-12
@@ -12,22 +12,22 @@ const MaxMessageBodyBytes = 256 * 1024
|
|||||||
|
|
||||||
// Message is a received message, decoupled from the generated protobuf type.
|
// Message is a received message, decoupled from the generated protobuf type.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
MessageID string
|
MessageID string
|
||||||
ReceiptHandle string
|
ReceiptHandle string
|
||||||
Body []byte
|
Body []byte
|
||||||
Attributes map[string]string
|
Attributes map[string]string
|
||||||
ReceiveCount int32
|
ReceiveCount int32
|
||||||
MessageGroupID string
|
MessageGroupID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessageInput is the input to SendMessage.
|
// SendMessageInput is the input to SendMessage.
|
||||||
type SendMessageInput struct {
|
type SendMessageInput struct {
|
||||||
QueueName string
|
QueueName string
|
||||||
Body []byte
|
Body []byte
|
||||||
Attributes map[string]string
|
Attributes map[string]string
|
||||||
MessageGroupID string // FIFO only
|
MessageGroupID string // FIFO only
|
||||||
MessageDeduplicationID string // FIFO only
|
MessageDeduplicationID string // FIFO only
|
||||||
DelaySeconds int32
|
DelaySeconds int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMessageOutput is the result of a successful SendMessage call.
|
// SendMessageOutput is the result of a successful SendMessage call.
|
||||||
|
|||||||
Reference in New Issue
Block a user