diff --git a/async.go b/async.go index 7b6171f..1630454 100644 --- a/async.go +++ b/async.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// Async is an asynchronous Event interface type Async interface { Event GetType() string diff --git a/context.go b/context.go index d598cf4..f73fdf3 100644 --- a/context.go +++ b/context.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// Context is event context type Context struct { Logger Logger DataBinding map[string]DataBinding diff --git a/databinding.go b/databinding.go index 23b5ac0..8cfcf3b 100644 --- a/databinding.go +++ b/databinding.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// DataBinding is event data binding type DataBinding interface { // TODO } diff --git a/doc.go b/doc.go index 164afe6..d10468f 100644 --- a/doc.go +++ b/doc.go @@ -1,3 +1,19 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio /* diff --git a/error.go b/error.go index d1705e4..17a601e 100644 --- a/error.go +++ b/error.go @@ -1,3 +1,5 @@ +// TODO: This will be documented once https://github.com/nuclio/nuclio-sdk/pull/21 is merged + package nuclio type WithStatusCode interface { diff --git a/event.go b/event.go index cdb7d7b..ead0f39 100644 --- a/event.go +++ b/event.go @@ -1,3 +1,19 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio import ( @@ -5,21 +21,18 @@ import ( "time" ) +// ErrUnsupported means Event does not support a method var ErrUnsupported = errors.New("Event does not support this interface") +// SourceInfoProvider is event source provider type SourceInfoProvider interface { - - // get the class of source (sync, async, etc) + // GetClass gets the class of source (sync, async, etc) GetClass() string - - // get specific kind of source (http, rabbit mq, etc) + // GetKind gets specific kind of source (http, rabbit mq, etc) GetKind() string } -// -// An event -// - +// Event is a nuclio event type Event interface { GetVersion() int GetID() ID @@ -43,99 +56,3 @@ type Event interface { GetURL() string GetMethod() string } - -// -// Abstract implementation of event -// - -type AbstractEvent struct { - sourceInfoProvider SourceInfoProvider - id ID - emptyByteArray []byte - emptyHeaders map[string]interface{} - emptyTime time.Time -} - -func (ae *AbstractEvent) GetVersion() int { - return 0 -} - -func (ae *AbstractEvent) SetSourceProvider(sourceInfoProvider SourceInfoProvider) { - ae.sourceInfoProvider = sourceInfoProvider -} - -func (ae *AbstractEvent) GetSource() SourceInfoProvider { - return ae.sourceInfoProvider -} - -func (ae *AbstractEvent) GetID() ID { - return ae.id -} - -func (ae *AbstractEvent) SetID(id ID) { - ae.id = id -} - -func (ae *AbstractEvent) GetContentType() string { - return "" -} - -func (ae *AbstractEvent) GetBody() []byte { - return ae.emptyByteArray -} - -func (ae *AbstractEvent) GetSize() int { - return 0 -} - -func (ae *AbstractEvent) GetHeader(key string) interface{} { - return nil -} - -func (ae *AbstractEvent) GetHeaderByteSlice(key string) []byte { - return ae.emptyByteArray -} - -func (ae *AbstractEvent) GetHeaderString(key string) string { - return string(ae.GetHeaderByteSlice(key)) -} - -func (ae *AbstractEvent) GetHeaders() map[string]interface{} { - return ae.emptyHeaders -} - -func (ae *AbstractEvent) GetTimestamp() time.Time { - return ae.emptyTime -} - -func (ae *AbstractEvent) GetPath() string { - return "" -} - -func (ae *AbstractEvent) GetURL() string { - return "" -} - -func (ae *AbstractEvent) GetMethod() string { - return "" -} - -func (ae *AbstractEvent) GetField(key string) interface{} { - return nil -} - -func (ae *AbstractEvent) GetFieldByteSlice(key string) []byte { - return nil -} - -func (ae *AbstractEvent) GetFieldString(key string) string { - return "" -} - -func (ae *AbstractEvent) GetFieldInt(key string) (int, error) { - return 0, ErrUnsupported -} - -func (ae *AbstractEvent) GetFields() map[string]interface{} { - return nil -} diff --git a/examples/event-sources/handler.go b/examples/event-sources/handler.go index 03f6a4e..9ae6bab 100644 --- a/examples/event-sources/handler.go +++ b/examples/event-sources/handler.go @@ -13,7 +13,7 @@ func GolangExample(context *nuclio.Context, event nuclio.Event) (interface{}, er return nuclio.Response{ StatusCode: 201, ContentType: "application/text", - Headers: map[string]string{ + Headers: map[string]interface{}{ "x-v3io-something": "30", }, Body: []byte("Response from golang"), diff --git a/logger.go b/logger.go index c9ec721..9ad6772 100644 --- a/logger.go +++ b/logger.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// Logger is logging interface type Logger interface { // emit a log entry of a given verbosity. the first argument may be an object, a string @@ -21,9 +38,9 @@ type Logger interface { InfoWith(format interface{}, vars ...interface{}) DebugWith(format interface{}, vars ...interface{}) - // flushes buffered logs, if applicable + // Flush flushes buffered logs, if applicable Flush() - // returns a child logger, if underlying logger supports hierarchal logging + // GetChild returns a child logger, if underlying logger supports hierarchal logging GetChild(name string) interface{} } diff --git a/response.go b/response.go index 4042795..0ecbb4f 100644 --- a/response.go +++ b/response.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// Response is a response object type Response struct { StatusCode int ContentType string diff --git a/sync.go b/sync.go index e335954..b728018 100644 --- a/sync.go +++ b/sync.go @@ -1,5 +1,22 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio +// Sync is synchronous event type Sync interface { Event GetHostAddress() string @@ -7,23 +24,3 @@ type Sync interface { GetWorkflowStep() string GetQuery() map[string]interface{} } - -type AbstractSync struct { - AbstractEvent -} - -func (as *AbstractSync) GetHostAddress() string { - return "" -} - -func (as *AbstractSync) GetRemoteAddress() string { - return "" -} - -func (as *AbstractSync) GetWorkflowStep() string { - return "" -} - -func (as *AbstractSync) GetQuery() map[string]interface{} { - return map[string]interface{}{} -} diff --git a/types.go b/types.go index d5775e6..7553c62 100644 --- a/types.go +++ b/types.go @@ -1,3 +1,19 @@ +/* +Copyright 2017 The Nuclio Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nuclio import (