Skip to content

Commit

Permalink
26.dockter.1 (#27)
Browse files Browse the repository at this point in the history
* #26 Add server options

* #26 Add server options

* #26 Prepare for versioned release

* #26 fixed gosec issues
  • Loading branch information
docktermj authored May 17, 2023
1 parent 649a388 commit d277376
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/go-security.yaml
Original file line number Diff line number Diff line change
@@ -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: ./...
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions grpcserver/grpcserver_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

// ----------------------------------------------------------------------------
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func main() {
Port: 8260,
Subject: aSubject,
}
aGrpcServer.Serve(ctx)

err = aGrpcServer.Serve(ctx)
if err != nil {
fmt.Print(err)
}
}
5 changes: 4 additions & 1 deletion notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit d277376

Please sign in to comment.