diff --git a/.github/workflows/go-security.yaml b/.github/workflows/go-security.yaml new file mode 100644 index 0000000..0b250bd --- /dev/null +++ b/.github/workflows/go-security.yaml @@ -0,0 +1,23 @@ +# Based on +# - https://github.com/securego/gosec + +name: go-security.yaml +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + tests: + runs-on: ubuntu-latest + env: + GO111MODULE: on + steps: + - name: Checkout Source + uses: actions/checkout@v3 + - name: Run Gosec Security Scanner + uses: securego/gosec@master + with: + args: ./... diff --git a/CHANGELOG.md b/CHANGELOG.md index adc4cc7..2b8c656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - +## [0.2.4] - 2023-05-16 + +### Added in 0.2.3 + +- Support for gRPC Serveroptions + ## [0.2.3] - 2023-05-12 ### Added in 0.2.3 diff --git a/grpcserver/grpcserver_impl.go b/grpcserver/grpcserver_impl.go index 4f268c4..3a85a8f 100644 --- a/grpcserver/grpcserver_impl.go +++ b/grpcserver/grpcserver_impl.go @@ -19,8 +19,9 @@ import ( // GrpcServerImpl is the default implementation of the GrpcServer interface. type GrpcServerImpl struct { observerpb.UnimplementedObserverServer - Subject subject.Subject - Port int + Port int + ServerOptions []grpc.ServerOption + Subject subject.Subject } // ---------------------------------------------------------------------------- @@ -46,7 +47,7 @@ func (subject *GrpcServerImpl) Serve(ctx context.Context) error { // Create server. - aGrpcServer := grpc.NewServer() + aGrpcServer := grpc.NewServer(subject.ServerOptions...) observerpb.RegisterObserverServer(aGrpcServer, subject) // Enable reflection. diff --git a/main.go b/main.go index 6090a56..183cfd0 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,8 @@ func main() { Port: 8260, Subject: aSubject, } - aGrpcServer.Serve(ctx) - + err = aGrpcServer.Serve(ctx) + if err != nil { + fmt.Print(err) + } } diff --git a/notifier/notifier.go b/notifier/notifier.go index 14a3a00..934215b 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -55,7 +55,10 @@ func Notify(ctx context.Context, observers subject.Subject, origin string, subje fmt.Printf("Error: %s", err.Error()) } else { if observers != nil { // For safety. - observers.NotifyObservers(ctx, string(message)) + err := observers.NotifyObservers(ctx, string(message)) + if err != nil { + panic(err) + } } } }