-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace deprecated tctl plugin example with codec server. (#238)
* Replace deprecated tctl plugin example with codec server.
- Loading branch information
1 parent
cf498e5
commit e7f0746
Showing
3 changed files
with
58 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"strconv" | ||
|
||
"github.com/temporalio/samples-go/encryption" | ||
|
||
"go.temporal.io/sdk/converter" | ||
) | ||
|
||
var portFlag int | ||
|
||
func init() { | ||
flag.IntVar(&portFlag, "port", 8081, "Port to listen on") | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
// This example codec server does not support varying config per namespace, | ||
// decoding for the Temporal Web UI or oauth. | ||
// For a more complete example of a codec server please see the codec-server sample at: | ||
// ../../codec-server. | ||
handler := converter.NewPayloadCodecHTTPHandler(&encryption.Codec{}, converter.NewZlibCodec(converter.ZlibCodecOptions{AlwaysEncode: true})) | ||
|
||
srv := &http.Server{ | ||
Addr: "0.0.0.0:" + strconv.Itoa(portFlag), | ||
Handler: handler, | ||
} | ||
|
||
errCh := make(chan error, 1) | ||
go func() { errCh <- srv.ListenAndServe() }() | ||
|
||
sigCh := make(chan os.Signal, 1) | ||
signal.Notify(sigCh, os.Interrupt) | ||
|
||
select { | ||
case <-sigCh: | ||
_ = srv.Close() | ||
case err := <-errCh: | ||
log.Fatal(err) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.