{"id":15789759,"url":"https://github.com/ytake/protoactor-go-persistence-pg","last_synced_at":"2025-05-07T09:01:15.747Z","repository":{"id":221368565,"uuid":"754173317","full_name":"ytake/protoactor-go-persistence-pg","owner":"ytake","description":"Go package with persistence provider for Proto Actor (Go) based on PostgreSQL.","archived":false,"fork":false,"pushed_at":"2024-12-15T16:03:59.000Z","size":44,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T08:21:28.780Z","etag":null,"topics":["actor-system","golang","protoactor-go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ytake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-07T14:43:32.000Z","updated_at":"2025-03-13T03:42:42.000Z","dependencies_parsed_at":"2024-02-16T10:25:12.044Z","dependency_job_id":"de8bd1dd-b2ea-4352-aab9-61be91c71226","html_url":"https://github.com/ytake/protoactor-go-persistence-pg","commit_stats":null,"previous_names":["ytake/protoactor-go-persistence-pg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-persistence-pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-persistence-pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-persistence-pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-persistence-pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ytake","download_url":"https://codeload.github.com/ytake/protoactor-go-persistence-pg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847477,"owners_count":21813451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor-system","golang","protoactor-go"],"created_at":"2024-10-04T22:03:21.278Z","updated_at":"2025-05-07T09:01:15.640Z","avatar_url":"https://github.com/ytake.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protoactor-go-persistence-pg\n\nGo package with persistence provider for Proto Actor (Go) based on PostgreSQL.\n\nusing [pgx v5](https://github.com/jackc/pgx)\n\n# Usage\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\n\t\"github.com/asynkron/protoactor-go/actor\"\n\t\"github.com/asynkron/protoactor-go/persistence\"\n\t\"github.com/jackc/pgx/v5\"\n\t\"github.com/jackc/pgx/v5/pgconn\"\n\t\"github.com/jackc/pgx/v5/pgxpool\"\n\t\"github.com/ytake/protoactor-go-persistence-pg\"\n)\n\ntype Actor struct {\n\tpersistence.Mixin\n}\n\nfunc (a *Actor) Receive(ctx actor.Context) {\n\t// example\n}\n\nfunc main() {\n\n\tconf, _ := pgxpool.ParseConfig(\"postgres://postgres:postgres@localhost:5432/sample?sslmode=disable\u0026pool_max_conns=10\")\n\n\tsystem := actor.NewActorSystem()\n\tctx := context.Background()\n\tconn, _ := pgxpool.NewWithConfig(ctx, conf)\n\tprovider, _ := persistencepg.New(ctx, 3, persistencepg.NewTable(), conn, system.Logger())\n\n\tprops := actor.PropsFromProducer(func() actor.Actor { return \u0026Actor{} },\n\t\tactor.WithReceiverMiddleware(persistence.Using(provider)))\n\n\tpid, _ := system.Root.SpawnNamed(props, \"persistent\")\n}\n\n```\n\n# Default table schema\n\nuse ulid as id(varchar(26)) and json as payload\n\n```sql\nCREATE TABLE journals\n(\n    id              VARCHAR(26) NOT NULL,\n    payload         JSONB NOT NULL,\n    sequence_number BIGINT,\n    actor_name      VARCHAR(255),\n    created_at      TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,\n    PRIMARY KEY (id),\n    UNIQUE (id),\n    UNIQUE (actor_name, sequence_number)\n);\n\nCREATE TABLE snapshots\n(\n    id              VARCHAR(26) NOT NULL,\n    payload         JSONB NOT NULL,\n    sequence_number BIGINT,\n    actor_name      VARCHAR(255),\n    created_at      TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,\n    PRIMARY KEY (id),\n    UNIQUE (id),\n    UNIQUE (actor_name, sequence_number)\n);\n\n```\n\n## change table name\n\nuse the interface to change the table name.\n\nfor journal table and snapshot table.\n\n```go \n// Schemaer is the interface that wraps the basic methods for a schema.\ntype Schemaer interface {\n    // JournalTableName returns the name of the journal table.\n    JournalTableName() string\n    // SnapshotTableName returns the name of the snapshot table.\n    SnapshotTableName() string\n    // ID returns the name of the id column.\n    ID() string\n    // Payload returns the name of the payload column.\n    Payload() string\n    // ActorName returns the name of the actor name column.\n    ActorName() string\n    // SequenceNumber returns the name of the sequence number column.\n    SequenceNumber() string\n    // Created returns the name of the created at column.\n    Created() string\n    // CreateTable returns the sql statement to create the table.\n    CreateTable() []string\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fprotoactor-go-persistence-pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fytake%2Fprotoactor-go-persistence-pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fprotoactor-go-persistence-pg/lists"}