mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-30 14:56:19 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package nexustest
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/nexus-rpc/sdk-go/nexus"
|
|
"github.com/stretchr/testify/require"
|
|
"go.temporal.io/server/common/testing/freeport"
|
|
)
|
|
|
|
func AllocListenAddress() string {
|
|
return fmt.Sprintf("localhost:%d", freeport.MustGetFreePort())
|
|
}
|
|
|
|
func NewNexusServer(t *testing.T, listenAddr string, handler nexus.Handler) {
|
|
hh := nexus.NewHTTPHandler(nexus.HandlerOptions{
|
|
Handler: handler,
|
|
})
|
|
srv := &http.Server{Addr: listenAddr, Handler: hh}
|
|
listener, err := net.Listen("tcp", listenAddr)
|
|
require.NoError(t, err)
|
|
errCh := make(chan error, 1)
|
|
go func() {
|
|
errCh <- srv.Serve(listener)
|
|
}()
|
|
|
|
t.Cleanup(func() {
|
|
// Graceful shutdown
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
err = srv.Shutdown(ctx)
|
|
if ctx.Err() != nil {
|
|
require.NoError(t, err)
|
|
require.ErrorIs(t, <-errCh, http.ErrServerClosed)
|
|
}
|
|
})
|
|
}
|
|
|
|
type Handler struct {
|
|
nexus.UnimplementedHandler
|
|
OnStartOperation func(ctx context.Context, service, operation string, input *nexus.LazyValue, options nexus.StartOperationOptions) (nexus.HandlerStartOperationResult[any], error)
|
|
OnCancelOperation func(ctx context.Context, service, operation, token string, options nexus.CancelOperationOptions) error
|
|
}
|
|
|
|
func (h Handler) StartOperation(ctx context.Context, service, operation string, input *nexus.LazyValue, options nexus.StartOperationOptions) (nexus.HandlerStartOperationResult[any], error) {
|
|
return h.OnStartOperation(ctx, service, operation, input, options)
|
|
}
|
|
|
|
func (h Handler) CancelOperation(ctx context.Context, service, operation, token string, options nexus.CancelOperationOptions) error {
|
|
return h.OnCancelOperation(ctx, service, operation, token, options)
|
|
}
|