Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed Mar 16, 2024
1 parent 969a99a commit 62d9868
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Go
on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22.x"
- name: Install dependencies
run: go get .
- name: Vet
run: go vet -v ./...
- name: Build
run: go build -v ./...
- name: Test with the Go CLI
run: go test -v ./...
8 changes: 3 additions & 5 deletions internal/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func NewMachine(handler restate.Handler, conn io.ReadWriter) *Machine {
}
}

// Start starts the state machine
func (m *Machine) Start(inner context.Context) error {
// reader starts a rea
msg, err := m.protocol.Read()
Expand All @@ -136,11 +137,8 @@ func (m *Machine) Start(inner context.Context) error {
return m.process(ctx, start)
}

// handle handler response and build proper response message
func (m *Machine) output(r *dynrpc.RpcResponse, err error) proto.Message {
// TODO: if err is terminal return outputStreamEntryMessage but if error is
// not terminal, return ErrorMessage instead.
//var output protocol.OutputStreamEntryMessage

if err != nil && restate.IsTerminalError(err) {
// terminal errors.
return &protocol.OutputStreamEntryMessage{
Expand Down Expand Up @@ -222,7 +220,7 @@ func (m *Machine) process(ctx *Context, start *wire.StartMessage) error {
return ErrUnexpectedMessage
}

log.Debug().Uint32("known entries", start.Payload.KnownEntries).Msg("known entires")
log.Trace().Uint32("known entries", start.Payload.KnownEntries).Msg("known entires")
m.entries = make([]wire.Message, 0, start.Payload.KnownEntries-1)

// we don't track the poll input entry
Expand Down
6 changes: 3 additions & 3 deletions server/restate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (r *Restate) discover() (resource *discovery.ServiceDiscoveryResponse, err
}

func (r *Restate) discoverHandler(writer http.ResponseWriter, _ *http.Request) {
log.Debug().Msg("discover called")
log.Trace().Msg("discover called")
writer.Header().Add("Content-Type", "application/proto")

response, err := r.discover()
Expand All @@ -97,7 +97,7 @@ func (r *Restate) discoverHandler(writer http.ResponseWriter, _ *http.Request) {

// takes care of function call
func (r *Restate) callHandler(service, fn string, writer http.ResponseWriter, request *http.Request) {
log.Debug().Str("service", service).Str("handler", fn).Msg("got a call to service function")
log.Trace().Str("service", service).Str("handler", fn).Msg("new invocation")

writer.Header().Add("content-type", "application/restate")

Expand Down Expand Up @@ -128,7 +128,7 @@ func (r *Restate) callHandler(service, fn string, writer http.ResponseWriter, re
log.Error().Err(err).Msg("failed to handle invocation")
}

log.Info().Msg("invocation ended")
log.Trace().Msg("invocation ended")
}

func (r *Restate) handler(writer http.ResponseWriter, request *http.Request) {
Expand Down
2 changes: 0 additions & 2 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func Echo(ctx restate.Context, name string) (string, error) {
return "", err
}

panic("failed intentionally after a call")

return fmt.Sprintf("echo: %s", string(response)), nil
}

Expand Down

0 comments on commit 62d9868

Please sign in to comment.