Skip to content

Commit

Permalink
big cleanup, contrib is no longer submodule but regular directory, no…
Browse files Browse the repository at this point in the history
…n actual modules archived
  • Loading branch information
refaktor committed Dec 19, 2023
1 parent 7c5f8fa commit 410b283
Show file tree
Hide file tree
Showing 30 changed files with 1,100 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# Enable all features for CI builds.
# TODO: add currently problematic tags: b_cayley,b_nng,b_qframe,b_ebitengine
run: |
go build -v -tags "b_sqlite,b_http,b_sql,b_postgres,b_bson,b_crypto,b_smtpd,b_mail,b_bcrypt,b_telegram,b_html,b_contrib,b_openai,b_email,b_mail,b_mysql,b_nats,b_psql,b_psutil,b_sxml,b_echo,b_webview,b_raylib,b_gtk" -o bin/rye
go build -v -tags "b_sqlite,b_http,b_sql,b_postgres,b_bson,b_crypto,b_smtpd,b_mail,b_bcrypt,b_telegram,b_html,b_contrib,b_openai,b_email,b_mail,b_mysql,b_psql,b_psutil,b_sxml,b_echo,b_webview" -o bin/rye
ls -l bin/rye
file bin/rye
go version -m bin/rye
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,20 @@ Most of them are more proof of concepts than full implementations. But it's not
* IO (!) - can be excluded at build time ⭐⭐
* Json - json parsing ⭐⭐
* Mysql - database ⭐
* NATS - messaging 🧱
* nng - nanomsg scalability protocols 🧱
* Postgresql - database ⭐
* Psutil - linux process management
* Regexp - regular expressions ⭐
* Smtpd - smtp server (receiver)
* Sqlite - database ⭐⭐
* Sxml - sax XML like streaming dialect
* Validation - validation dialect ⭐⭐
* Webview - Webview GUI (🧱) if problematic to build
* Webview - Webview GUI

### Contrib - will be community / third party integrations
* Amazon AWS
* Bleve full text search
* Cayley - graph database 🧱
* GTK - GUI framework 🧱
* OpenAI - OpenAI API
* QFrame - a fast dataframe implementation 🧱
* Postmark - email sending service
* Raylib - 2D graphich library / game engine 🧱
* Telegram bot - telegram bots
* Ebitengine - 2d game engine

Expand Down
2 changes: 2 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# rye-contrib
repo for contributed, third party or in general less-official bindings and builtin functions. It's a submodule of rye repo.
127 changes: 127 additions & 0 deletions contrib/aws/builtins_aws.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
//go:build b_aws
// +build b_aws

package aws

import (
"bytes"

"github.com/refaktor/rye/env"
"github.com/refaktor/rye/evaldo"

"fmt"

"github.com/go-gomail/gomail"

"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ses"
"github.com/aws/aws-sdk-go-v2/service/ses/types"
//"github.com/aws/aws-sdk-go/aws"
//"github.com/aws/aws-sdk-go/aws/client"
//"github.com/aws/aws-sdk-go/aws/session"
//"github.com/aws/aws-sdk-go/service/ses"
)

var Builtins_aws = map[string]*env.Builtin{

"new-aws-session": {
Argsn: 1,
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
switch region := arg0.(type) {
case env.String:
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region.Value))
fmt.Println(cfg)
fmt.Println(err)
if err != nil {
return evaldo.MakeError(ps, "Error creating new AWS session: "+err.Error())
}
return *env.NewNative(ps.Idx, cfg, "aws-session")
default:
return evaldo.MakeError(ps, "A1 not String")
}
},
},

"aws-session//open-ses": {
Argsn: 1,
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
switch cfg := arg0.(type) {
case env.Native:

svc := ses.NewFromConfig(cfg.Value.(aws.Config))
//svc := ses.New(sess.Value.(client.ConfigProvider))
fmt.Println(svc)
return *env.NewNative(ps.Idx, svc, "aws-ses-session")
default:
return evaldo.MakeError(ps, "Arg 1 not native.")
}
},
},

"aws-ses-session//send-raw": {
Argsn: 4,
Doc: "[ ses-session* gomail-message from-email recipients ]",
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
switch svc := arg0.(type) {
case env.Native:
switch msg := arg1.(type) { // gomail-message
case env.Native:
switch recps := arg2.(type) { // recipients
case env.Block:
switch fromMl := arg3.(type) { // recipients
case env.Email:

var recipients []string
for rec := range recps.Series.S {
switch rec2 := recps.Series.S[rec].(type) {
case env.String:
recipients = append(recipients, rec2.Value)
case env.Email:
recipients = append(recipients, rec2.Address)
}
}

fmt.Println(recipients)

fmt.Println(msg)

fromEmail := fromMl.Address

fmt.Println(recipients)

var emailRaw bytes.Buffer
msg.Value.(*gomail.Message).WriteTo(&emailRaw)

// create new raw message
message := types.RawMessage{Data: emailRaw.Bytes()}

fmt.Println("111")
input := &ses.SendRawEmailInput{Source: &fromEmail, Destinations: recipients, RawMessage: &message}

fmt.Println("222")
// send raw email
_, err := svc.Value.(*ses.Client).SendRawEmail(context.TODO(), input)
if err != nil {
return evaldo.MakeError(ps, err.Error())
}
fmt.Println("SHOULD SEND")
default:
return evaldo.MakeError(ps, "A4 not String")

}
default:
return evaldo.MakeError(ps, "A3 not Block")
}
default:
return evaldo.MakeError(ps, "A2 not Native")
}
default:
return evaldo.MakeError(ps, "A1 not Native")
}
return nil
},
},
}
10 changes: 10 additions & 0 deletions contrib/aws/builtins_aws_not.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !b_aws
// +build !b_aws

package aws

import (
"github.com/refaktor/rye/env"
)

var Builtins_aws = map[string]*env.Builtin{}
Loading

0 comments on commit 410b283

Please sign in to comment.