-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move internal package to types (#23)
- Loading branch information
Showing
13 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package runner | ||
|
||
import ( | ||
"github.com/bivas/rivi/runner/internal" | ||
"github.com/bivas/rivi/runner/local" | ||
"github.com/bivas/rivi/runner/types" | ||
) | ||
|
||
var defaultHookListenerQueueProvider internal.HookListenerQueueProvider = local.CreateHookListenerQueue | ||
var defaultHookListenerQueueProvider types.HookListenerQueueProvider = local.CreateHookListenerQueue | ||
|
||
func SetHookListenerQueueProvider(fn internal.HookListenerQueueProvider) { | ||
func SetHookListenerQueueProvider(fn types.HookListenerQueueProvider) { | ||
defaultHookListenerQueueProvider = fn | ||
} | ||
|
||
func CreateHookListenerQueue() internal.HookListenerQueue { | ||
func CreateHookListenerQueue() types.HookListenerQueue { | ||
return defaultHookListenerQueueProvider() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package runner | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bivas/rivi/runner/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type testHookListenerQueue struct { | ||
Created bool | ||
} | ||
|
||
func (*testHookListenerQueue) Enqueue(*types.Message) { | ||
panic("implement me") | ||
} | ||
|
||
func TestSetHookListenerQueueProvider(t *testing.T) { | ||
queue := &testHookListenerQueue{false} | ||
SetHookListenerQueueProvider(func() types.HookListenerQueue { | ||
queue.Created = true | ||
return queue | ||
}) | ||
assert.False(t, queue.Created, "created should be false") | ||
result := CreateHookListenerQueue() | ||
assert.NotNil(t, result, "test result") | ||
_, ok := result.(*testHookListenerQueue) | ||
assert.True(t, ok, "same type") | ||
assert.True(t, queue.Created, "created") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package runner | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewHookListener(t *testing.T) { | ||
result, err := NewHookListener("") | ||
assert.NoError(t, err, "new failed") | ||
assert.NotNil(t, result, "nil runner") | ||
_, ok := result.(*hookListener) | ||
assert.True(t, ok, "must be of type hook lisetner") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package local | ||
|
||
import ( | ||
"github.com/bivas/rivi/runner/internal" | ||
"github.com/bivas/rivi/runner/types" | ||
"github.com/bivas/rivi/util/log" | ||
) | ||
|
||
type channelHookListenerQueue struct { | ||
incoming chan *internal.Message | ||
incoming chan *types.Message | ||
} | ||
|
||
func (c *channelHookListenerQueue) Enqueue(data *internal.Message) { | ||
func (c *channelHookListenerQueue) Enqueue(data *types.Message) { | ||
if data == nil { | ||
close(c.incoming) | ||
return | ||
} | ||
c.incoming <- data | ||
} | ||
|
||
func channelHookListenerQueueProvider() internal.HookListenerQueue { | ||
func channelHookListenerQueueProvider() types.HookListenerQueue { | ||
log.Get("hook.listener.queue").DebugWith( | ||
log.MetaFields{ | ||
log.F("type", "channel")}, "Creating hook listener queue provider") | ||
incomingHooks := make(chan *internal.Message) | ||
incomingHooks := make(chan *types.Message) | ||
handler := NewChannelHookHandler(incomingHooks) | ||
go handler.Run() | ||
return &channelHookListenerQueue{incomingHooks} | ||
} | ||
|
||
func CreateHookListenerQueue() internal.HookListenerQueue { | ||
func CreateHookListenerQueue() types.HookListenerQueue { | ||
return channelHookListenerQueueProvider() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package internal | ||
package types | ||
|
||
type HookHandler interface { | ||
Run() | ||
|
2 changes: 1 addition & 1 deletion
2
runner/internal/hook_listener_queue.go → runner/types/hook_listener_queue.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package internal | ||
package types | ||
|
||
type HookListenerQueue interface { | ||
Enqueue(*Message) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package internal | ||
package types | ||
|
||
type JobHandler interface { | ||
Send(*Message) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package internal | ||
package types | ||
|
||
import ( | ||
"github.com/bivas/rivi/config/client" | ||
|